Fix support for Ctrl-C on the macosx backend.#25966
Merged
tacaswell merged 2 commits intomatplotlib:mainfrom Aug 9, 2023
Merged
Fix support for Ctrl-C on the macosx backend.#25966tacaswell merged 2 commits intomatplotlib:mainfrom
tacaswell merged 2 commits intomatplotlib:mainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 askipvariable.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