diff options
author | Julian Sparber <julian@sparber.net> | 2021-09-13 16:29:30 +0200 |
---|---|---|
committer | Julian Sparber <julian@sparber.net> | 2021-09-13 17:19:05 +0200 |
commit | cdc1fa166dad68fe158b10ae0fea8a3a27f1051f (patch) | |
tree | 1454335f4143796bd5d4c4db821f1814a71d5d85 | |
parent | f572ca52d237e628cc61036a394b46a50dd433ee (diff) | |
download | gtk+-cdc1fa166dad68fe158b10ae0fea8a3a27f1051f.tar.gz |
stack: Dispose children before emitting items-changed
This makes sure that the `GListModel` returned by
`gtk_stack_get_pages()` actually has the items removed before
`items-changed` is emitted.
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4255
-rw-r--r-- | gtk/gtkstack.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index dffc603452..469a25714a 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -690,13 +690,14 @@ gtk_stack_dispose (GObject *obj) GtkStack *stack = GTK_STACK (obj); GtkStackPrivate *priv = gtk_stack_get_instance_private (stack); GtkWidget *child; - - if (priv->pages) - g_list_model_items_changed (G_LIST_MODEL (priv->pages), 0, g_list_length (priv->children), 0); + guint n_pages = g_list_length (priv->children); while ((child = gtk_widget_get_first_child (GTK_WIDGET (stack)))) stack_remove (stack, child, TRUE); + if (priv->pages) + g_list_model_items_changed (G_LIST_MODEL (priv->pages), 0, n_pages, 0); + G_OBJECT_CLASS (gtk_stack_parent_class)->dispose (obj); } |