Skip to content

FIX: allow re-shown Qt windows to be re-destroyed #27313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

tacaswell
Copy link
Member

When a Qt window is closed we do not strip off the Qt components and it is technically possible to re-show it. However, the latch we use to detect re-entrant destruction does not get reset so the figure can not be re-destroyed.

More subtle behavior details discovered while working on mpl-gui.

When a Qt window is closed we do not strip off the Qt components and it
is technically possible to re-show it.  However, the latch we use to
detect re-entrant destruction does not get reset so the figure can not be
re-destroyed.
@tacaswell tacaswell added this to the v3.9.0 milestone Nov 13, 2023
Copy link
Member

@ksunden ksunden left a comment

Choose a reason for hiding this comment

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

Seems at the very least more correct, my only concern would be if something gets "destroyed" and "reopened" in quick succession, whether the flag would be set back to "False" too soon? (That would likely mean it is being controlled by different threads (or odd ordering of operations from the qt event loop), for instance, so not sure it is likely to be an actual problem)

Even if it was set back to False befor it got checked, not obvious to me that it would be incorrect, And I have the slight sense that for it to become problematic, it would require in fact going back and forth more than just once, at that.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Looks ok. There's a small chance for weird edge cases. But it's hard to think of an actual one. And even if this can break in a transitional state, a final show() will recover a consistent state.

@timhoffm timhoffm merged commit 6cc36ef into matplotlib:main Nov 13, 2023
@tacaswell tacaswell deleted the mnt/qt_undestroy branch November 14, 2023 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants