[gtk/gtk-4-4] stack: Dispose children before emitting items-changed



commit 137a62cb944158a25220ef496000946dfc211b45
Author: Julian Sparber <julian sparber net>
Date:   Mon Sep 13 16:29:30 2021 +0200

    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

 gtk/gtkstack.c | 7 ++++---
 1 file 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);
 }
 


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