Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix missing return value in closeButtonPressed.#21792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Accidentally removed inf7a432a.
Also, explicitly checking for whether zoombutton/panbutton are non-nullis unnecessary, as objc explicitly defines sending a message to null asa noop. Also, they should never be nil anyways...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This update looks good.
For the other updates:
-Werror
seems to compile fine for me locally without any warnings, so I agree this seems sensible to add in.The manager isn't available on the view there, so I think we'd have to store that somewhere on the window and then call super to get to that method. However, I'm a bit confused why we need that chunk of code at all... I think that even calling
window.close()
programatically would have closed the window by this point, so we shouldn't have to worry about that case?
Dropping that code works for me interactively with multiple windows as expected.
diff --git a/src/_macosx.m b/src/_macosx.mindex 64875fe7f1..5e3bd4fc96 100755--- a/src/_macosx.m+++ b/src/_macosx.m@@ -226,7 +226,6 @@ - (void)windowDidResize:(NSNotification*)notification; - (View*)initWithFrame:(NSRect)rect; - (void)setCanvas: (PyObject*)newCanvas; - (void)windowWillClose:(NSNotification*)notification;-- (BOOL)windowShouldClose:(NSNotification*)notification; - (BOOL)isFlipped; - (void)mouseEntered:(NSEvent*)event; - (void)mouseExited:(NSEvent*)event;@@ -1291,7 +1290,11 @@ - (NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen*)screen return suggested; }-- (BOOL)closeButtonPressed { gil_call_method(manager, "close"); }+- (BOOL)closeButtonPressed+{+ gil_call_method(manager, "close");+ return YES;+} - (void)close {@@ -1506,27 +1509,6 @@ - (void)windowWillClose:(NSNotification*)notification PyGILState_Release(gstate); }-- (BOOL)windowShouldClose:(NSNotification*)notification-{- NSWindow* window = [self window];- NSEvent* event = [NSEvent otherEventWithType: NSEventTypeApplicationDefined- location: NSZeroPoint- modifierFlags: 0- timestamp: 0.0- windowNumber: 0- context: nil- subtype: WINDOW_CLOSING- data1: 0- data2: 0];- [NSApp postEvent: event atStart: true];- if ([window respondsToSelector: @selector(closeButtonPressed)]) {- BOOL closed = [((Window*) window) closeButtonPressed];- /* If closed, the window has already been closed via the manager. */- if (closed) { return NO; }- }- return YES;-}- - (void)mouseEntered:(NSEvent *)event { PyGILState_STATE gstate;
I'mpretty sure when I made that PR matplotlib wouldn't compile with -Werror, and it didn't seem trivial to make that a possibility. |
Accidentally removed inf7a432a.
Closesf7a432a#r61013322. Would be nice if we could run with -Werror instead, which would have caught this, but I assume@dopplershift had a good reason to only use -Werror=unguarded-availability in#17956?
It's also not completely clear to me why the only call to closeButtonPressed (in windowShouldClose) is protected by respondsToSelector, and whether it could just be inlined there instead, using something like
Still, this patch should fix the main problem at hand...
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).