[nautilus/wip/corey/fix-sort: 8/9] list-view: Clear sorter changed signal handler during list-view dispose




commit 921609917547b516afb473ad8e030e80a802e490
Author: Corey Berla <corey berla me>
Date:   Sun Oct 16 13:07:11 2022 -0700

    list-view: Clear sorter changed signal handler during list-view dispose
    
    We need to clear the signal when list-view is freed because otherwise
    if it's cleared when the GtkSorter is freed, the list-view would
    have already been freed and we now depends on the list-view
    being there.

 src/nautilus-list-view.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 9b2a717a7..0960693c5 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1150,7 +1150,7 @@ nautilus_list_view_init (NautilusListView *self)
     sorter = gtk_multi_sorter_new ();
     gtk_multi_sorter_append (sorter, g_object_ref (GTK_SORTER (directories_sorter)));
     gtk_multi_sorter_append (sorter, g_object_ref (gtk_column_view_get_sorter (self->view_ui)));
-    g_signal_connect_object (sorter, "changed", G_CALLBACK (on_sorter_changed), self, G_CONNECT_AFTER);
+    g_signal_connect_after (sorter, "changed", G_CALLBACK (on_sorter_changed), self);
 
     model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
     nautilus_view_model_set_sorter (model, GTK_SORTER (sorter));
@@ -1173,6 +1173,13 @@ static void
 nautilus_list_view_dispose (GObject *object)
 {
     NautilusListView *self = NAUTILUS_LIST_VIEW (object);
+    NautilusViewModel *model;
+    GtkSorter *sorter;
+
+    model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
+    sorter = nautilus_view_model_get_sorter (model);
+
+    g_signal_handlers_disconnect_by_func (sorter, on_sorter_changed, self);
 
     g_clear_object (&self->file_path_base_location);
     g_clear_pointer (&self->factory_to_column_map, g_hash_table_destroy);


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