From 370ab8aa52055bddbaa20f483e590268a50fe708 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 4d18cfcdf7..00e1f63af3 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4026,6 +4026,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, @@ -4053,7 +4055,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);