Skip to content

Commit

Permalink
Don't call QApplication.setQuitOnLastWindowClosed(False).
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anntzer committed Aug 30, 2023
1 parent 6bf3fe9 commit 6aa0cbc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,10 @@ def make_qt_app_for_kernel(gui, kernel):
set_qt_api_env_from_gui(gui)

# This import is guaranteed to work now:
from IPython.external.qt_for_kernel import QtCore, QtGui
from IPython.external.qt_for_kernel import QtCore
from IPython.lib.guisupport import get_app_qt4

kernel.app = get_app_qt4([" "])
if isinstance(kernel.app, QtGui.QApplication):
kernel.app.setQuitOnLastWindowClosed(False)

kernel.app.qt_event_loop = QtCore.QEventLoop(kernel.app)


Expand Down

0 comments on commit 6aa0cbc

Please sign in to comment.