Duplicate file entries after double-clicking path button in file dialog

Bug #239085 reported by Diaa Sami
30
Affects Status Importance Assigned to Milestone
gtk+2.0 (Ubuntu)
Fix Released
Low
Unassigned
gtk-qt-engine-kde4 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Ubuntu hardy heron final with KDE3 installed
libgtk2.0-0: 2.12.9-3ubuntu4
kdesktop: 4:3.5.9-0ubuntu7.2

Step to reproduce the bug:
In KDE, Open the file dialog in any GTK application(say gedit), regardless of the location in the file system, double-click on the last button in the path bar which should represent the current folder .

What was expected:
Either nothing should happen or the contents of the current folder should be refreshed.

What happened instead:
Each item in the current folder is listed twice.

I was able to reproduce the bug consistently on 2 machines, I tried the same sequence in gnome but it works properly.

Revision history for this message
Sebastien Bacher (seb128) wrote :

thank you for your bug report, not confirming on my hardy installation, do you have the issue when using GNOME?

Changed in gtk+2.0:
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Diaa Sami (diaa.sami) wrote :

I mentioned this already, I couldn't reproduce the bug when using GNOME.

Revision history for this message
Sebastien Bacher (seb128) wrote :

likely another qt gtk engine bug

Changed in gtk+2.0:
status: Incomplete → New
Revision history for this message
Jonathan Thomas (echidnaman) wrote :

I can reproduce this in the kde4 version of gtk-qt-engine as well.

Revision history for this message
Diaa Sami (diaa.sami) wrote :

I noticed that on my other machine(a laptop) where the bug is reproducible, gtk-qt-engine is not installed so it may not be a gtk-qt-engine bug, please see the image attached

Revision history for this message
adw (adw) wrote :

I am seeing this in Gnome/XFCE. I am running Hardy, and my install started out as Xubuntu Feisty.

I don't have gtk-qt-engine installed.

Revision history for this message
Jonathan Thomas (echidnaman) wrote :

Ok then probably not a gtk-qt-engine bug. But since I don't know which package would be appropriate, I'll just invalid the gtk-qt-engine-kde4 one so that this bug doesn't disappear.

Changed in gtk-qt-engine-kde4:
status: New → Invalid
Revision history for this message
adw (adw) wrote :

This always happens for me when I have the 'Location' entry box on.
It never happens when I have it off.
In Diaa Sami's screenshot I also see that it is on.

Can anyone confirm this behaviour?

Revision history for this message
Sebastien Bacher (seb128) wrote :

could you describe how to trigger the issue on a new ubuntu installation? are you sure that's a gtk bug?

Changed in gtk+2.0:
status: New → Incomplete
Revision history for this message
adw (adw) wrote :

It's the GTK file chooser isn't it?

I don't have a clean installation to test on, but try this:
1. Open a GTK 'Open file' dialog.
2. Enable the location field (button in top-left of dialog, or Ctrl+L).
3. Double click one of the path component buttons.

Revision history for this message
adw (adw) wrote :

Actually, the duplicate says this is probably a bug in libgnomeui. Feel free to move if you think that's better (because I don't really know what I'm doing ;).

Revision history for this message
Sebastien Bacher (seb128) wrote :

could you run "dpkg -l | grep gtk" and attach the information to a comment?

Revision history for this message
Sebastien Bacher (seb128) wrote :

rather "dpkg -l | grep engines"

Revision history for this message
adw (adw) wrote :

$ dpkg -l|grep engines
ii gtk2-engines 1:2.14.1-0ubuntu1 theme engines for GTK+ 2.x
ii gtk2-engines-pixbuf 2.12.9-3ubuntu4 Pixbuf-based theme for GTK+ 2.x

Revision history for this message
Sebastien Bacher (seb128) wrote :

no idea about the issue but it's likely something specific to your configuration, to debug by somebody having the issue, you can try using a new user on the same installation and see if you still get the issue, could be some user configuration

Revision history for this message
adw (adw) wrote :

I created a new user, but it has the same problem.

Also, it doesn't just happen if I double click the buttons. If I get focus on one and press Enter twice within about 2 seconds, the same thing happens.

Changed in gtk+2.0:
status: Incomplete → New
Revision history for this message
adw (adw) wrote :

I have analyzed and solved the problem I was seeing.

Let's look at gtk+2.0-2.12.9/gtk/gtkfilesystemmodel.c.
In the callback function got_root_folder_cb, there is this code:

 if (gtk_file_folder_is_finished_loading (model->root_folder))
   g_signal_emit (model, file_system_model_signals[FINISHED_LOADING], 0);
 else
   g_signal_connect_object (model->root_folder, "finished-loading",
       G_CALLBACK (root_folder_finished_loading_cb), model, 0);

Basically, this means: if the folder is already loaded, tell the dialog we're done, otherwise wait for the folder to load (and then tell the dialog).
The function then goes on to populate the model with the files in the folder:

 gtk_file_folder_list_children (model->root_folder, &roots, NULL);
 ...
 for (tmp_list = roots; tmp_list; tmp_list = tmp_list->next) { ... }

This is where things go wrong; it seems that this loop isn't necessary at all. The model is already populated in do_files_added.
If the folder hasn't been loaded yet, this doesn't even do anything because gtk_file_folder_list_children will return an empty list. But if the folder IS already loaded, then this loop will add all files a second time!

However, there is another question: Why does the above call to gtk_file_folder_is_finished_loading only return true on the second path bar click? In other words, why isn't the 'loaded' status reset before the second click?
Well, there is some sort of caching going on, for a duration of FOLDER_CACHE_LIFETIME. And guess what, it's exactly 2 seconds.

So, how do we solve the problem? Simply remove the superfluous loop mentioned above. Of course this might have nasty side effects, so someone who's familiar with gtk's internals should have a look at what's going on here.
Now another issue crops up. The selection doesn't show up after the second click. Maybe someone else can figure that one out.

Revision history for this message
Sebastien Bacher (seb128) wrote :

could you open the bug on bugzilla.gnome.org and attach your change there for comments? there is no gtk upstream hackers in the ubuntu team so it would be better to use the gnome bugzilla there

Revision history for this message
adw (adw) wrote :

Argh, it seems that the loop is already gone in SVN (since r20342: 2008-06-10 Carlos Garnacho <email address hidden>, Bug 520874 - Should use gio directly).

I can't get it to compile unfortunately, but I assume it's fixed.

Revision history for this message
Sebastien Bacher (seb128) wrote :

closing the bug then since the new version is already in intrepid

Changed in gtk+2.0:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Patches

Remote bug watches

Bug watches keep track of this bug in other bug trackers.