From b1dbcb05d3ec43654d78e2662ae22162561c8270 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 17 Oct 2013 10:40:01 +0300 Subject: [PATCH] Use windowShouldClose rather than windowWillClose 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/graphics/cocoa/cocoawindow.m b/source/graphics/cocoa/cocoawindow.m index 9ed5133..cbf6722 100644 --- a/source/graphics/cocoa/cocoawindow.m +++ b/source/graphics/cocoa/cocoawindow.m @@ -5,7 +5,7 @@ @interface WindowDelegate: NSObject -- (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 -- 2.43.0