[libhandy] stackable-box: Fix ordering in children_reversed



commit 4e52d65e2595cdf6753c618f9dff55a9b4f34783
Author: Alex Angelou <ubuntu1aggelalex gmail com>
Date:   Tue Mar 30 22:13:01 2021 +0300

    stackable-box: Fix ordering in children_reversed
    
    When adding a child, we update the regular child list, then update the
    reversed child list using the length of the regular one. However, by the
    time we use it, it has already changed as we've just added an element, so
    store the length before adding it.
    
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/67
    Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/88

 src/hdy-stackable-box.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/hdy-stackable-box.c b/src/hdy-stackable-box.c
index 80adc80c..4d003c0e 100644
--- a/src/hdy-stackable-box.c
+++ b/src/hdy-stackable-box.c
@@ -2922,13 +2922,14 @@ hdy_stackable_box_insert_child_after (HdyStackableBox *self,
   } else {
     HdyStackableBoxChildInfo *sibling_info = find_child_info_for_widget (self, sibling);
     gint sibling_info_pos = g_list_index (self->children, sibling_info);
+    gint length = g_list_length (self->children);
 
     self->children =
       g_list_insert (self->children, child_info,
                      sibling_info_pos + 1);
     self->children_reversed =
       g_list_insert (self->children_reversed, child_info,
-                     g_list_length (self->children) - sibling_info_pos - 1);
+                     length - sibling_info_pos - 1);
   }
 
   if (self->visible_child)


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