[nautilus/wip/corey/fix-sort: 8/8] list-view: Set model sorter to NULL on dispose




commit 2797e21c33d5a32e1bf33202bd1a8f450cd318e6
Author: António Fernandes <antoniof gnome org>
Date:   Fri Oct 21 00:22:27 2022 +0100

    list-view: Set model sorter to NULL on dispose
    
    This avoids future emissions of a "changed" signal during destruction.
    
    Also fix setter not to connect to signals when the sorter is NULL.

 src/nautilus-list-view.c  | 4 ++++
 src/nautilus-view-model.c | 9 ++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index b8b7f7ed2..95e622d68 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1207,6 +1207,10 @@ static void
 nautilus_list_view_dispose (GObject *object)
 {
     NautilusListView *self = NAUTILUS_LIST_VIEW (object);
+    NautilusViewModel *model;
+
+    model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
+    nautilus_view_model_set_sorter (model, NULL);
 
     g_clear_object (&self->file_path_base_location);
     g_clear_pointer (&self->factory_to_column_map, g_hash_table_destroy);
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index ba59329f2..2d472ef6c 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -301,9 +301,12 @@ nautilus_view_model_set_sorter (NautilusViewModel *self,
         g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTER]);
     }
 
-    self->sorter_changed_id = g_signal_connect (self->sorter, "changed",
-                                                G_CALLBACK (on_sorter_changed), self);
-    g_list_store_sort (self->internal_model, compare_data_func, self);
+    if (self->sorter != NULL)
+    {
+        self->sorter_changed_id = g_signal_connect (self->sorter, "changed",
+                                                    G_CALLBACK (on_sorter_changed), self);
+        g_list_store_sort (self->internal_model, compare_data_func, self);
+    }
 }
 
 GQueue *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]