widget: Reset alloc_needed_on_child before allocating children
authorIvan Molodetskikh <yalterz@gmail.com>
Mon, 27 Feb 2023 22:42:16 +0000 (14:42 -0800)
committerIvan Molodetskikh <yalterz@gmail.com>
Tue, 28 Feb 2023 05:38:42 +0000 (21:38 -0800)
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

index 667b0d107f03c9065134f89182625ebe762fcd64..ca6f5403b371ba65ee3663417ce7403c340019e2 100644 (file)
@@ -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);