src/video/cocoa/SDL_cocoamessagebox.m
changeset 6832 156e608ec4ef
parent 6714 146d1d7ecdc4
child 6836 b0ca1571caf3
     1.1 --- a/src/video/cocoa/SDL_cocoamessagebox.m	Fri Feb 01 17:09:01 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamessagebox.m	Sun Jan 06 19:04:53 2013 +0300
     1.3 @@ -39,41 +39,39 @@
     1.4  {
     1.5      Cocoa_RegisterApp();
     1.6  
     1.7 -    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1.8 -
     1.9 -    NSAlert* alert = [[NSAlert alloc] init];
    1.10 +    @autoreleasepool {
    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 alloc] initWithUTF8String: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 +        const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons;
    1.44 +        int i;
    1.45 +        for (i = 0; i < messageboxdata->numbuttons; ++i) {
    1.46 +            NSButton *button = [alert addButtonWithTitle:[[NSString alloc] initWithUTF8String:buttons[i].text]];
    1.47 +            if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
    1.48 +                [button setKeyEquivalent:@"\r"];
    1.49 +            } else if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
    1.50 +                [button setKeyEquivalent:@"\033"];
    1.51 +            } else {
    1.52 +                [button setKeyEquivalent:@""];
    1.53 +            }
    1.54          }
    1.55 +
    1.56 +        NSInteger clicked = [alert runModal];
    1.57 +        clicked -= NSAlertFirstButtonReturn;
    1.58 +        *buttonid = buttons[clicked].buttonid;
    1.59 +        [alert release];
    1.60      }
    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  }
    1.71