Repository navigation
Conversation
| # See https://github.com/silx-kit/silx/issues/4748 | ||
| # Widgets can be created without being added to a layout (e.g. by | ||
| # clear or getDataPriority). Hide them explicitly, else Qt shows | ||
| # them when their parent becomes visible. | ||
| self.__widget.hide() |
There was a problem hiding this comment.
Maybe one of the two (link to the issue + the comment) can be removed.
There was a problem hiding this comment.
This sounds risky, where do they get shown?
It would be best to review the logic of why they are created but not added to a layout.
There was a problem hiding this comment.
A QStackedWidget is behind and it shown when DataViewer._setDisplayedView is called (setCurrentIndex)
This is using a QStackedLayout that I am not familiar with to be honest. But it handles the visibility of the widgets composing the stack.
The views are created on the fly when .getWidget() is called (where the bug fix is proposed).
But it can be called not only when displaying the view but only when setData is called - which was our use case. It seems also to be called when clear or remove view is called. So it would create it... to remove it.
So to me it doesn't seems risk in the sense that today visibility is handled by the stack setCurrentIndex. On the other side it seems that some improvements could be done. But to be honest that's a thread I wouldn't pull.
There was a problem hiding this comment.
I am okay to merge the quickfix but I agree with @t20100 that we should search for a cleaner approach.
There was a problem hiding this comment.
This is not really a fix, it "hides" the problem: There should be no orphan widget.
I have a look at it and suggest an alternative if I find one.
There was a problem hiding this comment.
it can be called not only when displaying the view but only when setData is called - which was our use case. It seems also to be called when clear or remove view is called. So it would create it... to remove it.
That's the root issue. I am +1 to fix it and avoid creating widgets only to clear or remove them.
The overall pattern would still be not robust because it does not guarantee that created widgets are added the the QStackWidget, but that would fix the actual issue.
There was a problem hiding this comment.
At least this is solving the original problem. Indeed let's see if we need more.
PR summary
Close #4748
When
DataViewer.setData()is called on a hidden viewer, sub-view widgets get created without necessarily being added to a layout.If they are not hidden explicitly they became visible at the same time as their parent (when the view is shown).
Testing
Check the script from the issue to reproduce and see that the bug is fixed.
AI Disclosure