diff src/video/cocoa/SDL_cocoaevents.m @ 1937:05e88d266921

Fixed Objective-C memory leaks Send an SDL quit event when Command-Q is pressed.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 25 Jul 2006 06:59:14 +0000
parents 83946ee0ff1f
children 25d6537feea4
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 25 06:22:42 2006 +0000
+++ b/src/video/cocoa/SDL_cocoaevents.m	Tue Jul 25 06:59:14 2006 +0000
@@ -37,6 +37,18 @@
 }
 @end
 
+@interface SDLAppDelegate : NSObject
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end
+
+@implementation SDLAppDelegate : NSObject
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+{
+    SDL_SendQuit();
+    return NSTerminateCancel;
+}
+@end
+
 static NSString *
 GetApplicationName(void)
 {
@@ -139,6 +151,9 @@
         }
         [NSApp finishLaunching];
     }
+    if ([NSApp delegate] == nil) {
+        [NSApp setDelegate:[[SDLAppDelegate alloc] init]];
+    }
     [NSApp setRunning];
     [pool release];
 }