GNOME Bugzilla – Bug 553211
GtkFileChooserButton unsets filter after first use of dialog
Last modified: 2010-05-02 19:24:37 UTC
It seems in GTK+ 2.14, that the currently selected filter of a GtkFileChooserButton is deselected after a file has been chosen. The problem is as follows: - create a GtkFileChooserButton, add some filters - click on the button, open the dialog, first filter is selected as expected - select a file, click Open - click on the button again, open the dialog, no filter is selected anymore This worked correctly in GTK+ 2.12.11.
Created attachment 119148 [details] testcase
A bit more info on this... I've just noticed on 2.14.2 this assertion is thrown: (gtk-file-chooser-button-test:7708): GLib-GIO-CRITICAL **: g_content_type_get_mime_type: assertion `type != NULL' failed Which I've traced here:
+ Trace 207059
show_and_select_files_finished_loading() is the function that calls set_current_filter(impl, NULL), unsetting the filter.
Created attachment 119442 [details] [review] patch Does this patch make things work as expected for you ?
Bug 553211 – GtkFileChooserButton unsets filter after first use * gtk/gtkfilechooserdefault.c (show_and_select_files): Also get the content-type, since it is used later on. Pointed out by Davyd Madeley.
Just trying this patch now against 2.14.3. I'm still experiencing the problem, but the patch does seem to have suppressed the warning.
*** Bug 559276 has been marked as a duplicate of this bug. ***
I can reproduce this bug in GTK+ 2.18.3 version
Created attachment 153282 [details] [review] patch Appears to fix the bug
More detailed description of the patch: When any FileChooserWidget changes from hidden to shown with one or more files selected, this problem occurs. Function show_and_select_files_finished_loading() tries to determine if any files are selected that are filtered out by the currently selected filter. If so, the filter is unset. The determination is done by calling get_is_file_filtered() for all selected files. get_is_file_filtered() uses the "standard::display-name" attribute, but that attribute hasn't been obtained in the show_and_select_file() function, causing show_and_select_files_finished_loading() to think that all selected files are filtered out and the filter always being unset.
What branch/release is this patch against ? It doesn't apply to either master or 2.18
It's against 2.18. I'm a newbie w.r.t. git, but have looked at http://live.gnome.org/GnomeLove/SubmittingPatches and http://live.gnome.org/Git/Developers and tried to follow the instructions as closely as possible. When I try to apply the patch to a newly checked out gtk-2-18 branch, I get a "space before tab in indent." warning but the patch is accepted by git (and as far as I can tell I haven't made a change to the spacing). Any idea what I'm doing wrong?
Looking at 2.19.6, I see that gtkfilechooserdefault.c has changed quite a bit compared to 2.18. One of the changes also fixed this bug, so it's fixed for 2.19.
Created attachment 154683 [details] [review] patch against gtk-2-18 branch New patch with whitespace issue fixed. This is for gtk-2-18 only, because the problem doesn't exist in master.
Comment on attachment 154683 [details] [review] patch against gtk-2-18 branch committed in the gtk-2-18 branch after Benjamin Otte review commit cac87b0a165fe1e92e38cc8f134a6e4657c7a837
The previous commit solves the problem in GTK+ 2.18. The bug doesn't exist in GTK+ 2.20 or master, so we can close this now.