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.
@interface WindowDelegate: NSObject <NSWindowDelegate>
@interface WindowDelegate: NSObject <NSWindowDelegate>
-- (void)windowWillClose:(NSNotification *)notification;
+- (BOOL)windowShouldClose:(id)sender;
@implementation WindowDelegate
@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);
if(window)
{
CocoaEvent event;
event.any.type = WINDOW_CLOSED;
event.any.window = window;
queue_event(window->display, &event);