Do not leak LayoutChild instances

Since the LayoutManager owns the LayoutChild it creates, it's also
responsible for mopping them up.
This commit is contained in:
Emmanuele Bassi 2019-06-17 09:26:39 +01:00
parent 636fbc0f1a
commit bd2349c0a0

View File

@ -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;