# HG changeset patch # User Goffi # Date 1579289623 -3600 # Node ID 8b6621cc142cd84359e094b50c98ca96db91d5d3 # Parent aa860c10acfc0474de91a039cd009eb2d567a5a2 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. diff -r aa860c10acfc -r 8b6621cc142c cagou/core/widgets_handler.py --- a/cagou/core/widgets_handler.py Fri Jan 17 18:44:35 2020 +0100 +++ b/cagou/core/widgets_handler.py Fri Jan 17 20:33:43 2020 +0100 @@ -87,6 +87,12 @@ return wid return next(iter(wid_list)) + def on_parent(self, __, new_parent): + if new_parent is None: + # we detach all children so CagouWidget.whwrapper won't link to this one + # anymore + self.clear_widgets() + @property def _left_wid(self): return self._main_wid(self._left_wids) @@ -351,7 +357,7 @@ def clear_widgets(self): current_slide = self.current_slide if current_slide is not None: - G.host._removeVisibleWidget(current_slide) + G.host._removeVisibleWidget(current_slide, ignore_missing=True) super().clear_widgets()