]> git.tdb.fi Git - libs/gui.git/commitdiff
Use windowShouldClose rather than windowWillClose
authorMikko Rasa <tdb@tdb.fi>
Thu, 17 Oct 2013 07:40:01 +0000 (10:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 17 Oct 2013 07:40:01 +0000 (10:40 +0300)
This prevents a crash when the autorelease pool is released (no clue what
exactly goes wrong) and allows the application to decide whether to close
the window or not.

source/graphics/cocoa/cocoawindow.m

index 9ed5133162d3c6ff791a62521b67624f38eb3550..cbf67222d7b91a60371a9180686220e52a997a2b 100644 (file)
@@ -5,7 +5,7 @@
 
 @interface WindowDelegate: NSObject <NSWindowDelegate>
 
-- (void)windowWillClose:(NSNotification *)notification;
+- (BOOL)windowShouldClose:(id)sender;
 
 @end
 
@@ -96,16 +96,18 @@ void hide_window(CocoaWindow *window)
 
 @implementation WindowDelegate
 
-- (void)windowWillClose:(NSNotification *)notification
+- (BOOL)windowShouldClose:(id)sender
 {
-       CocoaWindow *window = lookup_window((NSWindow *)[notification object]);
+       CocoaWindow *window = lookup_window((NSWindow *)sender);
        if(window)
        {
                CocoaEvent event;
                event.any.type = WINDOW_CLOSED;
                event.any.window = window;
                queue_event(window->display, &event);
+               return NO;
        }
+       return YES;
 }
 
 @end