Skip to content

Commit 0c603a6

Browse files
committed
Close all plot windows of a blocking show() on Ctrl+C
Addresses the Qt part of #23385. It appears that `qapp.quit()` does not automatically close the windows of the app. We therefore do it explicitly. A unit test for this would be quite complex. Test this by hand by Ctrl+C in an interactive shell.
1 parent 6501209 commit 0c603a6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/matplotlib/backends/qt_compat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ def _may_clear_sock(*args):
215215
def handle(*args):
216216
nonlocal handler_args
217217
handler_args = args
218+
for window in qapp.allWindows():
219+
window.close()
218220
qapp.quit()
219221

220222
signal.signal(signal.SIGINT, handle)

0 commit comments

Comments
 (0)