[gtk/wip/ebassi/constraint-layout: 19/69] Do not leak LayoutChild instances



commit bd2349c0a0993c8f05a4eabf51e8793398f2b6eb
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Jun 17 09:26:39 2019 +0100

    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(+)
---
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;


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