Skip to content

Fix support for Ctrl-C on the macosx backend.#25966

Merged
tacaswell merged 2 commits intomatplotlib:mainfrom
anntzer:mcc
Aug 9, 2023
Merged

Fix support for Ctrl-C on the macosx backend.#25966
tacaswell merged 2 commits intomatplotlib:mainfrom
anntzer:mcc

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented May 24, 2023

Support is largely copy-pasted from, and tests are shared with, the qt implementation (qt_compat._maybe_allow_interrupt, #13306), the main difference being that what we need from QSocketNotifier, as well as the equivalent for QApplication.quit(), are reimplemented in ObjC.

qt_compat._maybe_allow_interrupt is also slightly cleaned up by moving out the "do-nothing" case (old_sigint_handler in (None, SIG_IGN, SIG_DFL)) and dedenting the rest, instead of keeping track of whether signals were actually manipulated via a skip variable.

Factoring out the common parts of _maybe_allow_interrupt is left as a follow-up.

(Test e.g. with
MPLBACKEND=macosx python -c "from pylab import *; plot(); show()" followed by Ctrl-C.)

Closes #3991 (which was closed as cantfix in #3991 (comment); likely much of #4006 can now be reverted).

Also closes #10002 by providing _macosx.stop as a private function to call [NSApp stop]; whether we want to make that public is another question.

PR summary

PR checklist

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can't stop macosx mainloop SIGINT is ignored by MacOSX backend

6 participants