src/video/cocoa/SDL_cocoamessagebox.m
changeset 6848 478ecc8a58b3
parent 6836 b0ca1571caf3
child 6885 700f1b25f77f
--- a/src/video/cocoa/SDL_cocoamessagebox.m	Mon Feb 11 17:25:58 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamessagebox.m	Mon Feb 11 17:39:52 2013 -0800
@@ -39,38 +39,40 @@
 {
     Cocoa_RegisterApp();
 
-    @autoreleasepool {
-        NSAlert* alert = [[NSAlert alloc] init];
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    NSAlert* alert = [[NSAlert alloc] init];
 
-        if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
-            [alert setAlertStyle:NSCriticalAlertStyle];
-        } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
-            [alert setAlertStyle:NSWarningAlertStyle];
-        } else {
-            [alert setAlertStyle:NSInformationalAlertStyle];
-        }
+    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
+        [alert setAlertStyle:NSCriticalAlertStyle];
+    } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
+        [alert setAlertStyle:NSWarningAlertStyle];
+    } else {
+        [alert setAlertStyle:NSInformationalAlertStyle];
+    }
 
-        [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
-        [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
+    [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
+    [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
 
-        const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
-        int i;
-        for (i = 0; i < messageboxdata->numbuttons; ++i) {
-            NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
-            if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
-                [button setKeyEquivalent:@"\r"];
-            } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
-                [button setKeyEquivalent:@"\033"];
-            } else {
-                [button setKeyEquivalent:@""];
-            }
+    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
+    int i;
+    for (i = 0; i < messageboxdata->numbuttons; ++i) {
+        NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
+        if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
+            [button setKeyEquivalent:@"\r"];
+        } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
+            [button setKeyEquivalent:@"\033"];
+        } else {
+            [button setKeyEquivalent:@""];
         }
+    }
 
-        NSInteger clicked = [alert runModal];
-        clicked -= NSAlertFirstButtonReturn;
-        *buttonid = buttons[clicked].buttonid;
-        [alert release];
-    }
+    NSInteger clicked = [alert runModal];
+    clicked -= NSAlertFirstButtonReturn;
+    *buttonid = buttons[clicked].buttonid;
+    [alert release];
+
+    [pool release];
 
     return 0;
 }