From: Carlos Garnacho Date: Wed, 8 Mar 2023 12:13:19 +0000 (+0100) Subject: gtkfilechooser: Keep GtkSearchEngine around for longer X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~5^2~40^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5fd2a6c8f3f84da5d00edc0f29b42a3a627d0df4;p=gtk4.git gtkfilechooser: Keep GtkSearchEngine around for longer Currently the GtkSearchEngine is torn down every time the search is stopped, which also means between typed characters. This prevents any of the optimizations that the GtkSearchEngine can do in the long run. Let the GtkSearchEngine stay around for longer, and only be disposed after search is cancelled, the filechooser moves onto a different mode than search, or is otherwise unmapped/disposed. While at it, remove an unused struct field. --- diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 2ab5050fd4..f915587849 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -328,7 +328,6 @@ struct _GtkFileChooserWidget guint show_type_column : 1; guint create_folders : 1; guint auto_selecting_first_row : 1; - guint starting_search : 1; guint browse_files_interaction_frozen : 1; }; @@ -2663,6 +2662,16 @@ location_bar_update (GtkFileChooserWidget *impl) gtk_widget_set_visible (impl->browse_new_folder_button, create_folder_visible); } +static void +search_clear_engine (GtkFileChooserWidget *impl) +{ + if (impl->search_engine) + { + g_signal_handlers_disconnect_by_data (impl->search_engine, impl); + g_clear_object (&impl->search_engine); + } +} + static void operation_mode_stop (GtkFileChooserWidget *impl, OperationMode mode) @@ -2673,6 +2682,7 @@ operation_mode_stop (GtkFileChooserWidget *impl, search_stop_searching (impl, TRUE); search_clear_model (impl, TRUE); gtk_widget_set_visible (impl->remote_warning_bar, FALSE); + search_clear_engine (impl); } } @@ -3076,6 +3086,7 @@ cancel_all_operations (GtkFileChooserWidget *impl) g_clear_object (&impl->file_exists_get_info_cancellable); search_stop_searching (impl, TRUE); + search_clear_engine (impl); } static void sorter_changed (GtkSorter *main_sorter, @@ -5774,8 +5785,6 @@ search_stop_searching (GtkFileChooserWidget *impl, if (impl->search_engine) { _gtk_search_engine_stop (impl->search_engine); - g_signal_handlers_disconnect_by_data (impl->search_engine, impl); - g_clear_object (&impl->search_engine); set_busy_cursor (impl, FALSE); gtk_widget_set_visible (impl->search_spinner, FALSE); @@ -5900,11 +5909,12 @@ static void search_entry_stop_cb (GtkFileChooserWidget *impl) { if (impl->search_engine) - search_stop_searching (impl, FALSE); + { + search_stop_searching (impl, FALSE); + search_clear_engine (impl); + } else g_object_set (impl, "search-mode", FALSE, NULL); - - impl->starting_search = FALSE; } /* Hides the path bar and creates the search entry */