src/video/cocoa/SDL_cocoamessagebox.m
changeset 6848 478ecc8a58b3
parent 6836 b0ca1571caf3
child 6885 700f1b25f77f
     1.1 --- a/src/video/cocoa/SDL_cocoamessagebox.m	Mon Feb 11 17:25:58 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamessagebox.m	Mon Feb 11 17:39:52 2013 -0800
     1.3 @@ -39,38 +39,40 @@
     1.4  {
     1.5      Cocoa_RegisterApp();
     1.6  
     1.7 -    @autoreleasepool {
     1.8 -        NSAlert* alert = [[NSAlert alloc] init];
     1.9 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    1.10 +
    1.11 +    NSAlert* alert = [[NSAlert alloc] init];
    1.12  
    1.13 -        if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
    1.14 -            [alert setAlertStyle:NSCriticalAlertStyle];
    1.15 -        } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
    1.16 -            [alert setAlertStyle:NSWarningAlertStyle];
    1.17 -        } else {
    1.18 -            [alert setAlertStyle:NSInformationalAlertStyle];
    1.19 -        }
    1.20 +    if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
    1.21 +        [alert setAlertStyle:NSCriticalAlertStyle];
    1.22 +    } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
    1.23 +        [alert setAlertStyle:NSWarningAlertStyle];
    1.24 +    } else {
    1.25 +        [alert setAlertStyle:NSInformationalAlertStyle];
    1.26 +    }
    1.27  
    1.28 -        [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
    1.29 -        [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
    1.30 +    [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
    1.31 +    [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
    1.32  
    1.33 -        const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
    1.34 -        int i;
    1.35 -        for (i = 0; i < messageboxdata->numbuttons; ++i) {
    1.36 -            NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
    1.37 -            if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
    1.38 -                [button setKeyEquivalent:@"\r"];
    1.39 -            } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
    1.40 -                [button setKeyEquivalent:@"\033"];
    1.41 -            } else {
    1.42 -                [button setKeyEquivalent:@""];
    1.43 -            }
    1.44 +    const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
    1.45 +    int i;
    1.46 +    for (i = 0; i < messageboxdata->numbuttons; ++i) {
    1.47 +        NSButton *button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
    1.48 +        if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
    1.49 +            [button setKeyEquivalent:@"\r"];
    1.50 +        } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
    1.51 +            [button setKeyEquivalent:@"\033"];
    1.52 +        } else {
    1.53 +            [button setKeyEquivalent:@""];
    1.54          }
    1.55 +    }
    1.56  
    1.57 -        NSInteger clicked = [alert runModal];
    1.58 -        clicked -= NSAlertFirstButtonReturn;
    1.59 -        *buttonid = buttons[clicked].buttonid;
    1.60 -        [alert release];
    1.61 -    }
    1.62 +    NSInteger clicked = [alert runModal];
    1.63 +    clicked -= NSAlertFirstButtonReturn;
    1.64 +    *buttonid = buttons[clicked].buttonid;
    1.65 +    [alert release];
    1.66 +
    1.67 +    [pool release];
    1.68  
    1.69      return 0;
    1.70  }