[gtk] stack: Fix a crash
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] stack: Fix a crash
- Date: Thu, 14 Feb 2019 17:27:14 +0000 (UTC)
commit 89d8ae043176183262536318ab8d2f06ab3a4ce1
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Feb 14 12:24:22 2019 -0500
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)
gtk/gtkstack.c | 4 ++++
1 file changed, 4 insertions(+)
---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]