comparison cagou/core/widgets_handler.py @ 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 a5dfc789eeaf
children 1b835bcfa663
comparison
equal deleted inserted replaced
270:89ba66464329 271:23d4358803c7
324 self._slides_update_lock = False 324 self._slides_update_lock = False
325 self.updateHiddenSlides() 325 self.updateHiddenSlides()
326 326
327 def onSlideChange(self, handler, new_slide): 327 def onSlideChange(self, handler, new_slide):
328 if self._former_slide is not None: 328 if self._former_slide is not None:
329 if self._former_slide is new_slide:
330 # FIXME: workaround for Kivy a95d67f (and above?), Carousel.current_slide
331 # binding now calls onSlideChange twice with the same widget (here
332 # "new_slide"). To be checked with Kivy team.
333 return
329 G.host._removeVisibleWidget(self._former_slide) 334 G.host._removeVisibleWidget(self._former_slide)
330 self._former_slide = new_slide 335 self._former_slide = new_slide
331 if new_slide is not None: 336 if new_slide is not None:
332 G.host._addVisibleWidget(new_slide) 337 G.host._addVisibleWidget(new_slide)
333 self.updateHiddenSlides() 338 self.updateHiddenSlides()