Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 07c0239

Browse filesBrowse files
authored
Merge pull request #27064 from timhoffm/fix-ctrl-c-qt
Close all plot windows of a blocking show() on Ctrl+C
2 parents a589856 + 73c0bd6 commit 07c0239
Copy full SHA for 07c0239

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _exec(obj):
163163

164164

165165
@contextlib.contextmanager
166-
def _maybe_allow_interrupt(qapp):
166+
def _maybe_allow_interrupt(qapp_or_eventloop):
167167
"""
168168
This manager allows to terminate a plot by sending a SIGINT. It is
169169
necessary because the running Qt backend prevents Python interpreter to
@@ -215,7 +215,9 @@ def _may_clear_sock(*args):
215215
def handle(*args):
216216
nonlocal handler_args
217217
handler_args = args
218-
qapp.quit()
218+
if hasattr(qapp_or_eventloop, 'closeAllWindows'):
219+
qapp_or_eventloop.closeAllWindows()
220+
qapp_or_eventloop.quit()
219221

220222
signal.signal(signal.SIGINT, handle)
221223
try:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.