Repository navigation
silx.gui.data: Fixed DataView creating orphan widgets - #4752
Conversation
| if self.isWidgetInitialized(): | ||
| self._clear() | ||
|
|
||
| def _clear(self): |
There was a problem hiding this comment.
Putting the check in clear avoids to take care of checking isWidgetInitialized in callers.
This is compatible with already existing external custom DataView which overrides clear. It would be best if they now override _clear but it still work as before (i.e. with the bug) if not.
| if view.isWidgetInitialized(): | ||
| self.__stack.removeWidget(view.getWidget()) |
There was a problem hiding this comment.
That was pointless before
|
|
||
| def clear(self): | ||
| for v in self.getViews(): | ||
| v.clear() |
There was a problem hiding this comment.
For composite views, isWidgetInitialized always returns False. I left it as it was, though it could be better to return True if one of the sub-views is initialized. 🤷
Clearing all their sub-views anyway (no-op if none is initialized).
| def clear(self): | ||
| for v in self.__views.keys(): | ||
| v.clear() |
There was a problem hiding this comment.
No longer needed _CompositeView implements it in a generic way.
|
According to @payno, this does not cover all orphan widgets cases but already fixes the main ones. There is a structural issue to fix: any call to |
<Module or Topic>: <Action> <Summary>(see contributing guidelines)PR summary
Alternative to PR #4749
This PR avoids the
DataViewmechanism to create orphan widgets when clearing or removing them and closes #4748.As said in #4749 (comment) :
AI Disclosure