src/video/cocoa/SDL_cocoakeyboard.m
changeset 6848 478ecc8a58b3
parent 6832 156e608ec4ef
child 6885 700f1b25f77f
     1.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Mon Feb 11 17:25:58 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Mon Feb 11 17:39:52 2013 -0800
     1.3 @@ -625,27 +625,28 @@
     1.4  Cocoa_StartTextInput(_THIS)
     1.5  {
     1.6      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     1.7 -    @autoreleasepool {
     1.8 -        NSView *parentView = [[NSApp keyWindow] contentView];
     1.9 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    1.10 +    NSView *parentView = [[NSApp keyWindow] contentView];
    1.11  
    1.12 -        /* We only keep one field editor per process, since only the front most
    1.13 -         * window can receive text input events, so it make no sense to keep more
    1.14 -         * than one copy. When we switched to another window and requesting for
    1.15 -         * text input, simply remove the field editor from its superview then add
    1.16 -         * it to the front most window's content view */
    1.17 -        if (!data->fieldEdit) {
    1.18 -            data->fieldEdit =
    1.19 -                [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
    1.20 -        }
    1.21 +    /* We only keep one field editor per process, since only the front most
    1.22 +     * window can receive text input events, so it make no sense to keep more
    1.23 +     * than one copy. When we switched to another window and requesting for
    1.24 +     * text input, simply remove the field editor from its superview then add
    1.25 +     * it to the front most window's content view */
    1.26 +    if (!data->fieldEdit) {
    1.27 +        data->fieldEdit =
    1.28 +            [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
    1.29 +    }
    1.30  
    1.31 -        if (![[data->fieldEdit superview] isEqual: parentView])
    1.32 -        {
    1.33 -            // DEBUG_IME(@"add fieldEdit to window contentView");
    1.34 -            [data->fieldEdit removeFromSuperview];
    1.35 -            [parentView addSubview: data->fieldEdit];
    1.36 -            [[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
    1.37 -        }
    1.38 +    if (![[data->fieldEdit superview] isEqual: parentView])
    1.39 +    {
    1.40 +        // DEBUG_IME(@"add fieldEdit to window contentView");
    1.41 +        [data->fieldEdit removeFromSuperview];
    1.42 +        [parentView addSubview: data->fieldEdit];
    1.43 +        [[NSApp keyWindow] makeFirstResponder: data->fieldEdit];
    1.44      }
    1.45 +
    1.46 +    [pool release];
    1.47  }
    1.48  
    1.49  void
    1.50 @@ -654,11 +655,11 @@
    1.51      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.52  
    1.53      if (data && data->fieldEdit) {
    1.54 -        @autoreleasepool {
    1.55 -            [data->fieldEdit removeFromSuperview];
    1.56 -            [data->fieldEdit release];
    1.57 -            data->fieldEdit = nil;
    1.58 -        }
    1.59 +        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    1.60 +        [data->fieldEdit removeFromSuperview];
    1.61 +        [data->fieldEdit release];
    1.62 +        data->fieldEdit = nil;
    1.63 +        [pool release];
    1.64      }
    1.65  }
    1.66