Mercurial > libervia-desktop-kivy
comparison cagou/core/widgets_handler.py @ 355:8b6621cc142c
core (widgets handler): clear widgets when WHWrapper is detached:
when WHWrapper is detached from parent, we call clear_widgets to detach children. This
avoid CagouWidget.whwrapper to lead to this now unused wrapper (this was causing a bug
when testing if a widget is attached and could be re-used, leading to the unnecessary
creation of new widgets).
Added ignore_missing when removing current_slide from visible widgets, to avoid error
logging if wrapper was not active.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 17 Jan 2020 20:33:43 +0100 |
parents | 19422bbd9c8e |
children | e1f56257cabc |
comparison
equal
deleted
inserted
replaced
354:aa860c10acfc | 355:8b6621cc142c |
---|---|
84 return None | 84 return None |
85 for wid in wid_list: | 85 for wid in wid_list: |
86 if wid._split != 'None': | 86 if wid._split != 'None': |
87 return wid | 87 return wid |
88 return next(iter(wid_list)) | 88 return next(iter(wid_list)) |
89 | |
90 def on_parent(self, __, new_parent): | |
91 if new_parent is None: | |
92 # we detach all children so CagouWidget.whwrapper won't link to this one | |
93 # anymore | |
94 self.clear_widgets() | |
89 | 95 |
90 @property | 96 @property |
91 def _left_wid(self): | 97 def _left_wid(self): |
92 return self._main_wid(self._left_wids) | 98 return self._main_wid(self._left_wids) |
93 | 99 |
349 del self.ellipse | 355 del self.ellipse |
350 | 356 |
351 def clear_widgets(self): | 357 def clear_widgets(self): |
352 current_slide = self.current_slide | 358 current_slide = self.current_slide |
353 if current_slide is not None: | 359 if current_slide is not None: |
354 G.host._removeVisibleWidget(current_slide) | 360 G.host._removeVisibleWidget(current_slide, ignore_missing=True) |
355 | 361 |
356 super().clear_widgets() | 362 super().clear_widgets() |
357 | 363 |
358 self.screen_manager = None | 364 self.screen_manager = None |
359 self.carousel = None | 365 self.carousel = None |