From 5a8f31faf2122a93a6188a34e332beda4e82873f Mon Sep 17 00:00:00 2001 From: Carlos Soriano Date: Wed, 22 Jul 2015 17:29:12 +0200 Subject: view: don't crash on view destroy if no model We stop loading the view on destroy, and we add a check on done_loading to not do some things if we are on destroy. But the check was checking for the slot not having a window, which actually has if the view is being destroyed while the slot is not, like when switching views. To avoid this crash, mark the model as NULL before all the checking, and check for the model, not for a window in the slot. --- src/nautilus-view.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/nautilus-view.c b/src/nautilus-view.c index 8546def63..14bf2f329 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -2547,6 +2547,10 @@ 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); @@ -2578,10 +2582,6 @@ nautilus_view_destroy (GtkWidget *object) view->details->reveal_selection_idle_id = 0; } - if (view->details->model) { - nautilus_directory_unref (view->details->model); - view->details->model = NULL; - } if (view->details->directory_as_file) { nautilus_file_unref (view->details->directory_as_file); @@ -2841,7 +2841,6 @@ done_loading (NautilusView *view, { GList *selection; gboolean do_reveal = FALSE; - NautilusWindow *window; if (!view->details->loading) { return; @@ -2849,12 +2848,9 @@ done_loading (NautilusView *view, nautilus_profile_start (NULL); - window = nautilus_view_get_window (view); - - /* This can be called during destruction, in which case there - * is no NautilusWindow any more. - */ - if (window != NULL) { + /* This can be called during destruction, in which case we set the model + * as NULL. */ + if (view->details->model != NULL) { nautilus_view_update_toolbar_menus (view); schedule_update_context_menus (view); schedule_update_status (view); -- cgit v1.2.1