[gtk/matthiasc/for-master: 17/17] inspector: Avoid losing a reference
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 17/17] inspector: Avoid losing a reference
- Date: Thu, 16 Jul 2020 11:14:54 +0000 (UTC)
commit 46eb51bc30fa5a3fa2bd81b4018804168afa6036
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jul 15 22:14:36 2020 -0400
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.
gtk/inspector/resource-list.c | 15 +++++++++------
1 file 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]