diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-07-15 22:14:36 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-07-16 07:14:01 -0400 |
commit | 46eb51bc30fa5a3fa2bd81b4018804168afa6036 (patch) | |
tree | b6802d87a48c855fb43e4bea6c93076ccfcad5ea /gtk/inspector | |
parent | 500dbaabc37b40c5e57f1e6343e893f57fbf004c (diff) | |
download | gtk+-46eb51bc30fa5a3fa2bd81b4018804168afa6036.tar.gz |
inspector: Avoid losing a reference
This was copying the example in the treelistrowsorter
docs that the previous commit fixed, so we apply
the same fix here.
Diffstat (limited to 'gtk/inspector')
-rw-r--r-- | gtk/inspector/resource-list.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c index 21e1096e34..63cf4745c2 100644 --- a/gtk/inspector/resource-list.c +++ b/gtk/inspector/resource-list.c @@ -694,6 +694,7 @@ constructed (GObject *object) GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object); GListModel *root_model; GListModel *sort_model; + GtkSorter *column_sorter; GtkSorter *sorter; g_signal_connect (rl->open_details_button, "clicked", @@ -709,7 +710,8 @@ constructed (GObject *object) NULL, NULL); - sorter = gtk_tree_list_row_sorter_new (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list))); + column_sorter = gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list)); + sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter)); sort_model = G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (rl->tree_model), sorter)); rl->selection = gtk_single_selection_new (sort_model); g_object_unref (root_model); @@ -764,14 +766,15 @@ set_property (GObject *object, } static void -finalize (GObject *object) +dispose (GObject *object) { GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object); - g_object_unref (rl->selection); - g_object_unref (rl->tree_model); + g_clear_pointer (&rl->stack, gtk_widget_unparent); + g_clear_object (&rl->selection); + g_clear_object (&rl->tree_model); - G_OBJECT_CLASS (gtk_inspector_resource_list_parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_inspector_resource_list_parent_class)->dispose (object); } static void @@ -889,7 +892,7 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass) object_class->get_property = get_property; object_class->set_property = set_property; object_class->constructed = constructed; - object_class->finalize = finalize; + object_class->dispose = dispose; widget_class->root = root; widget_class->unroot = unroot; |