changeset 271:23d4358803c7

widgets_handler: work around the double call of onSlideChange: with Kivy dev version a95d67f (the one currently used in Python for Android), onSlideChange which is binded on current_slide was called twice with the same widget, resulting in widgets unexpectedly deleted. This patch fixes it by abording the callback if new_slide is the same as _former_slide, i.e. if the widget is not actually changed. Started a discussion with upstream Kivy team to check if this is a bug or feature.
author Goffi <goffi@goffi.org>
date Wed, 20 Mar 2019 09:29:44 +0100
parents 89ba66464329
children c4990a7d5dbd
files cagou/core/widgets_handler.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/widgets_handler.py	Wed Mar 20 09:29:44 2019 +0100
+++ b/cagou/core/widgets_handler.py	Wed Mar 20 09:29:44 2019 +0100
@@ -326,6 +326,11 @@
 
     def onSlideChange(self, handler, new_slide):
         if self._former_slide is not None:
+            if self._former_slide is new_slide:
+                # FIXME: workaround for Kivy a95d67f (and above?), Carousel.current_slide
+                #        binding now calls onSlideChange twice with the same widget (here
+                #        "new_slide"). To be checked with Kivy team.
+                return
             G.host._removeVisibleWidget(self._former_slide)
         self._former_slide = new_slide
         if new_slide is not None: