[nautilus] view-model: Stop freeing already free model on view-item dispose



commit 39e98edca46af9bb4e6e32147a20aa8d20f2c356
Author: Corey Berla <corey berla me>
Date:   Sun May 29 07:14:48 2022 -0700

    view-model: Stop freeing already free model on view-item dispose
    
    When view-item is disposed (i.e. switching from grid view to list view)
    assertions are failed when attempting to free self->internal_model.
    The GtkMultiSelection self->selection_model took ownership of
    internal_model and thus already freed it on dispose.  Increase
    ref count when creating internal_model.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2148

 src/nautilus-view-model.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 947bfa2c2..69cdeb0f8 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -214,7 +214,7 @@ constructed (GObject *object)
     G_OBJECT_CLASS (nautilus_view_model_parent_class)->constructed (object);
 
     self->internal_model = g_list_store_new (NAUTILUS_TYPE_VIEW_ITEM_MODEL);
-    self->selection_model = gtk_multi_selection_new (G_LIST_MODEL (self->internal_model));
+    self->selection_model = gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (self->internal_model)));
     self->map_files_to_model = g_hash_table_new (NULL, NULL);
 
     g_signal_connect_swapped (self->internal_model, "items-changed",


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