From 75a417e33708dab2bdb2f784a8952e085a12bf03 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 27 Feb 2023 14:42:16 -0800 Subject: [PATCH] widget: Reset alloc_needed_on_child before allocating children Reset alloc_needed_on_child *before* allocating the children. This is because some child's size_allocate() may call queue_allocate(), which will bubble up alloc_needed_on_child. An example of this happening is with GtkScrollable implementations, which are supposed to configure their adjustments in size_allocate(), which will cause GtkScrollbar's GtkRange to notice and queue_allocate() on itself. If we reset alloc_needed_on_child after this happens, then our children will have a lingering alloc_needed_on_child and will not receive an allocation. This commit fixes widgets occasionally losing an allocation when this scenario happens. --- gtk/gtkwidget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 667b0d107f..ca6f5403b3 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4035,6 +4035,8 @@ gtk_widget_allocate (GtkWidget *widget, priv->height = adjusted.height; priv->baseline = baseline; + priv->alloc_needed_on_child = FALSE; + if (priv->layout_manager != NULL) { gtk_layout_manager_allocate (priv->layout_manager, widget, @@ -4062,7 +4064,6 @@ gtk_widget_allocate (GtkWidget *widget, gtk_widget_ensure_resize (widget); priv->alloc_needed = FALSE; - priv->alloc_needed_on_child = FALSE; gtk_widget_update_paintables (widget);