summaryrefslogtreecommitdiff
path: root/gtk/gtkstack.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-02-14 12:24:22 -0500
committerMatthias Clasen <mclasen@redhat.com>2019-02-14 12:24:22 -0500
commit89d8ae043176183262536318ab8d2f06ab3a4ce1 (patch)
treec4caddf3bf66156c0bcd380d15b7b9e3fd0f37ed /gtk/gtkstack.c
parentfb444919267892e34903b2c304e8c2b2b46bb154 (diff)
downloadgtk+-89d8ae043176183262536318ab8d2f06ab3a4ce1.tar.gz
stack: Fix a crash
We need to remove the weak pointer, as the stack switcher can keep the list model alive beyond the stack. This was observed to cause crashes: ==16870== Invalid write of size 8 ==16870== at 0x5168A4E: g_nullify_pointer (gutils.c:2284) ==16870== by 0x522C500: weak_refs_notify (gobject.c:2791) ==16870== by 0x50FE7BC: g_data_set_internal (gdataset.c:407) ==16870== by 0x50FECA7: g_datalist_id_set_data_full (gdataset.c:670) ==16870== by 0x5227EB4: g_object_real_dispose (gobject.c:1056) ==16870== by 0x522D295: g_object_unref (gobject.c:3309) ==16870== by 0x4AF849F: unset_stack (gtkstackswitcher.c:428) ==16870== by 0x4AF892E: gtk_stack_switcher_dispose (gtkstackswitcher.c:527)
Diffstat (limited to 'gtk/gtkstack.c')
-rw-r--r--gtk/gtkstack.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index eb9504f6ef..003bc2088e 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -600,6 +600,7 @@ gtk_stack_dispose (GObject *obj)
if (priv->pages)
g_list_model_items_changed (G_LIST_MODEL (priv->pages), 0, g_list_length (priv->children), 0);
+
gtk_container_foreach (GTK_CONTAINER (obj), remove_child, obj);
G_OBJECT_CLASS (gtk_stack_parent_class)->dispose (obj);
@@ -611,6 +612,9 @@ gtk_stack_finalize (GObject *obj)
GtkStack *stack = GTK_STACK (obj);
GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
+ if (priv->pages)
+ g_object_remove_weak_pointer (G_OBJECT (priv->pages), (gpointer *)&priv->pages);
+
gtk_stack_unschedule_ticks (stack);
g_clear_pointer (&priv->last_visible_node, gsk_render_node_unref);