From bd2349c0a0993c8f05a4eabf51e8793398f2b6eb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 17 Jun 2019 09:26:39 +0100 Subject: Do not leak LayoutChild instances Since the LayoutManager owns the LayoutChild it creates, it's also responsible for mopping them up. --- gtk/gtklayoutmanager.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gtk/gtklayoutmanager.c') diff --git a/gtk/gtklayoutmanager.c b/gtk/gtklayoutmanager.c index 1aa7724d49..547c76bbdf 100644 --- a/gtk/gtklayoutmanager.c +++ b/gtk/gtklayoutmanager.c @@ -199,9 +199,24 @@ gtk_layout_manager_real_create_layout_child (GtkLayoutManager *manager, NULL); } +static void +gtk_layout_manager_finalize (GObject *gobject) +{ + GtkLayoutManager *self = GTK_LAYOUT_MANAGER (gobject); + GtkLayoutManagerPrivate *priv = gtk_layout_manager_get_instance_private (self); + + g_clear_pointer (&priv->layout_children, g_hash_table_unref); + + G_OBJECT_CLASS (gtk_layout_manager_parent_class)->finalize (gobject); +} + static void gtk_layout_manager_class_init (GtkLayoutManagerClass *klass) { + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = gtk_layout_manager_finalize; + klass->get_request_mode = gtk_layout_manager_real_get_request_mode; klass->measure = gtk_layout_manager_real_measure; klass->allocate = gtk_layout_manager_real_allocate; -- cgit v1.2.1