Skip to content
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

Don't call QApplication.setQuitOnLastWindowClosed(False). #1142

Merged
merged 1 commit into from Sep 2, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 30, 2023

That setting previously caused
plt.plot(); print("pre"); plt.show(block=True); print("post") to block after the show() call even after closing the Matplotlib figure window ("post" was never printed).

The new behavior (printing "post" after the window is closed) is consistent with plain IPython.

The setQuitOnLastWindowClosed call came in (with no additional explanation) in the very first commit implementing qt support (bec2d41, in 2010) and seems to have never been touched since then.

This should close #4367 (which is really an ipykernel issue per spyder-ide/spyder#4367 (comment)), which had previously been closed as "can't fix, workaround available". Attn @ccordoba12 who commented on the spyder issue.

That setting previously caused
`plt.plot(); print("pre"); plt.show(block=True); print("post")`
to block after the `show()` call *even* after closing the Matplotlib
figure window ("post" was never printed).

The new behavior (printing "post" after the window is closed) is
consistent with plain IPython.

The setQuitOnLastWindowClosed call came in (with no additional
explanation) in the very first commit implementing qt support (bec2d41,
in 2010) and seems to have never been touched since then.
@blink1073 blink1073 added the bug label Sep 1, 2023
@ccordoba12
Copy link
Member

Thanks @anntzer for taking a look at this problem! I tested your PR locally and it worked as expected for me on Linux.

Did you test it on Windows? If not, I can ask one of the Spyder devs to do it just to be extra sure.

The setQuitOnLastWindowClosed call came in (with no additional explanation) in the very first commit implementing qt support (bec2d41, in 2010) and seems to have never been touched since then.

It was probably needed in the old Qt4 days, but it seems to not be anymore.

@anntzer
Copy link
Contributor Author

anntzer commented Sep 1, 2023

Did you test it on Windows?

Not directly (it's a bit tricky for me to access a Windows dev setup), but I did check that on Windows, in the Spyder console, I can run QApplication.instance().setQuitOnLastWindowClosed(False) (effectively undoing the setting from ipykernel) and then plt.show(block=False) does work as desired.

@ccordoba12
Copy link
Member

Ok, then this looks good to me.

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

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

Thanks @anntzer!

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

Thank you!

@blink1073 blink1073 merged commit 44c1759 into ipython:main Sep 2, 2023
28 of 32 checks passed
@anntzer anntzer deleted the qolwc branch September 2, 2023 10:57
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.

None yet

3 participants