[libadwaita] carousel: Null check child when scrolling



commit d24fae0a9b1410ea64acfdd881187935b853ce1b
Author: Milan Šťastný <milan stastnej ch>
Date:   Mon Oct 18 10:26:03 2021 +0000

    carousel: Null check child when scrolling
    
    Fix a crash when scrolling in an empty carousel.

 src/adw-carousel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index e41d761c..087daac0 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -379,9 +379,13 @@ scroll_to (AdwCarousel *self,
   if (self->animation)
     adw_animation_stop (self->animation);
 
-  self->animation_source_position = self->position;
   self->animation_target_child = find_child_info (self, widget);
 
+  if (self->animation_target_child == NULL)
+    return;
+
+  self->animation_source_position = self->position;
+
   self->animation =
     adw_animation_new (GTK_WIDGET (self), 0, 1, duration,
                        (AdwAnimationTargetFunc) scroll_animation_value_cb,


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