[gtk/matthiasc/for-master: 18/19] flowbox: Avoid an assertion in snapshot()



commit de7acf42286f3ce1364736889183207ec2b584da
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 13 20:33:25 2020 -0400

    flowbox: Avoid an assertion in snapshot()
    
    The api contract for size_allocate() vfuncs is
    that they must allocate all the children that are
    going to be snapshotted in snapshot(). The flowbox
    size_allocate() was just bailing out when the children
    request a size of 0x0, leading to an assertion in
    snapshot() vfunc later. Just allocate all children
    a size of 0x0 in this case.

 gtk/gtkflowbox.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 5c022d45cd..ddbf34fa33 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -1561,7 +1561,28 @@ gtk_flow_box_size_allocate (GtkWidget *widget,
    */
   get_max_item_size (box, priv->orientation, &min_item_size, &nat_item_size);
   if (nat_item_size <= 0)
-    return;
+    {
+      child_allocation.x = 0;
+      child_allocation.y = 0;
+      child_allocation.width = 0;
+      child_allocation.height = 0;
+
+      for (iter = g_sequence_get_begin_iter (priv->children);
+           !g_sequence_iter_is_end (iter);
+           iter = g_sequence_iter_next (iter))
+        {
+          GtkWidget *child;
+
+          child = g_sequence_get (iter);
+
+          if (!child_is_visible (child))
+            continue;
+
+          gtk_widget_size_allocate (child, &child_allocation, -1);
+        }
+
+      return;
+    }
 
   /* By default flow at the natural item width */
   line_length = avail_size / (nat_item_size + item_spacing);


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