src/video/cocoa/SDL_cocoamessagebox.m
changeset 6832 156e608ec4ef
parent 6714 146d1d7ecdc4
child 6836 b0ca1571caf3
--- a/src/video/cocoa/SDL_cocoamessagebox.m	Fri Feb 01 17:09:01 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamessagebox.m	Sun Jan 06 19:04:53 2013 +0300
@@ -39,41 +39,39 @@
 {
     Cocoa_RegisterApp();
 
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    NSAlert* alert = [[NSAlert alloc] init];
+    @autoreleasepool {
+        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 alloc] initWithUTF8String: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 alloc] initWithUTF8String: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;
 }