Skip to content

Commit

Permalink
Close all plot windows of a blocking show() on Ctrl+C
Browse files Browse the repository at this point in the history
Addresses the Qt part of matplotlib#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.
  • Loading branch information
timhoffm committed Oct 11, 2023
1 parent 6501209 commit 0c603a6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/matplotlib/backends/qt_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def _may_clear_sock(*args):
def handle(*args):
nonlocal handler_args
handler_args = args
for window in qapp.allWindows():
window.close()
qapp.quit()

signal.signal(signal.SIGINT, handle)
Expand Down

0 comments on commit 0c603a6

Please sign in to comment.