From 394fde4835c5e04d14e0a61bf1470a0112486057 Mon Sep 17 00:00:00 2001 From: Carlos Soriano Date: Thu, 23 Jul 2015 17:57:07 +0200 Subject: search-directory: make sure to stop the search if no clients Until now we were not stopping the search if no callbacks from clients were present. That happened when the user canceled the search while the search directory was waiting for its files metadata, since that async call was not canceled. This was actually making nautilus freeze on situations where the search was so expensive that other threads couldn't cope with it. To fix it, make sure we stop the search if no clients are present as callbacks, and make sure we stop the load of the view when we cancel the async call in the stop_loadin handler of the view. --- libnautilus-private/nautilus-search-directory.c | 13 +++++++------ src/nautilus-view.c | 12 +++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/libnautilus-private/nautilus-search-directory.c b/libnautilus-private/nautilus-search-directory.c index bdd5b1caf..68d7f2c7c 100644 --- a/libnautilus-private/nautilus-search-directory.c +++ b/libnautilus-private/nautilus-search-directory.c @@ -492,8 +492,8 @@ search_cancel_callback (NautilusDirectory *directory, search->details->callback_list = g_list_remove (search->details->callback_list, search_callback); search_callback_destroy (search_callback); - - return; + + goto done; } /* Check for a pending callback */ @@ -503,11 +503,12 @@ search_cancel_callback (NautilusDirectory *directory, search->details->pending_callback_list = g_list_remove (search->details->pending_callback_list, search_callback); search_callback_destroy (search_callback); - - if (!search->details->pending_callback_list) { - stop_search (search); - } } + +done: + if (!search->details->callback_list && !search->details->pending_callback_list) { + stop_search (search); + } } static void diff --git a/src/nautilus-view.c b/src/nautilus-view.c index 14bf2f329..3d8f1ca7e 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -2546,12 +2546,6 @@ nautilus_view_destroy (GtkWidget *object) view = NAUTILUS_VIEW (object); - disconnect_model_handlers (view); - if (view->details->model) { - nautilus_directory_unref (view->details->model); - view->details->model = NULL; - } - nautilus_view_stop_loading (view); for (node = view->details->scripts_directory_list; node != NULL; node = next) { @@ -6896,7 +6890,6 @@ load_directory (NautilusView *view, } old_directory = view->details->model; - disconnect_model_handlers (view); nautilus_directory_ref (directory); view->details->model = directory; @@ -7132,6 +7125,11 @@ nautilus_view_stop_loading (NautilusView *view) { g_return_if_fail (NAUTILUS_IS_VIEW (view)); + disconnect_model_handlers (view); + if (view->details->model) { + nautilus_directory_unref (view->details->model); + view->details->model = NULL; + } unschedule_display_of_pending_files (view); reset_update_interval (view); -- cgit v1.2.1