Skip to content

silx.gui.data._DataView: Fix display of widgets not part of a layout - #4749

Closed
payno wants to merge 1 commit into
mainfrom
4748-dataviewer-orphan-cell
Closed

payno wants to merge 1 commit into
mainfrom
4748-dataviewer-orphan-cell

Conversation

@payno

@payno payno commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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

  • Claude Opus 5.5 used

@payno payno linked an issue Oct 22, 2026 that may be closed by this pull request
Comment on lines +137 to +141
# 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()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe one of the two (link to the issue + the comment) can be removed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@loichuder loichuder Oct 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay to merge the quickfix but I agree with @t20100 that we should search for a cleaner approach.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #4752 is not enough, this workaround can be added.

I created issue #4756 to track this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least this is solving the original problem. Indeed let's see if we need more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataViewer: orphan cell

3 participants