src/video/cocoa/SDL_cocoaclipboard.m
changeset 6848 478ecc8a58b3
parent 6832 156e608ec4ef
child 6885 700f1b25f77f
     1.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m	Mon Feb 11 17:25:58 2013 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m	Mon Feb 11 17:39:52 2013 -0800
     1.3 @@ -45,46 +45,51 @@
     1.4  Cocoa_SetClipboardText(_THIS, const char *text)
     1.5  {
     1.6      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     1.7 -
     1.8 +    NSAutoreleasePool *pool;
     1.9      NSPasteboard *pasteboard;
    1.10      NSString *format = GetTextFormat(_this);
    1.11  
    1.12 -    @autoreleasepool {
    1.13 -        pasteboard = [NSPasteboard generalPasteboard];
    1.14 -        data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    1.15 -        [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
    1.16 -    }
    1.17 -    
    1.18 +    pool = [[NSAutoreleasePool alloc] init];
    1.19 +
    1.20 +    pasteboard = [NSPasteboard generalPasteboard];
    1.21 +    data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
    1.22 +    [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
    1.23 +
    1.24 +    [pool release];
    1.25 +
    1.26      return 0;
    1.27  }
    1.28  
    1.29  char *
    1.30  Cocoa_GetClipboardText(_THIS)
    1.31  {
    1.32 +    NSAutoreleasePool *pool;
    1.33      NSPasteboard *pasteboard;
    1.34      NSString *format = GetTextFormat(_this);
    1.35      NSString *available;
    1.36      char *text;
    1.37  
    1.38 -    @autoreleasepool {
    1.39 -        pasteboard = [NSPasteboard generalPasteboard];
    1.40 -        available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
    1.41 -        if ([available isEqualToString:format]) {
    1.42 -            NSString* string;
    1.43 -            const char *utf8;
    1.44 +    pool = [[NSAutoreleasePool alloc] init];
    1.45  
    1.46 -            string = [pasteboard stringForType:format];
    1.47 -            if (string == nil) {
    1.48 -                utf8 = "";
    1.49 -            } else {
    1.50 -                utf8 = [string UTF8String];
    1.51 -            }
    1.52 -            text = SDL_strdup(utf8);
    1.53 +    pasteboard = [NSPasteboard generalPasteboard];
    1.54 +    available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
    1.55 +    if ([available isEqualToString:format]) {
    1.56 +        NSString* string;
    1.57 +        const char *utf8;
    1.58 +
    1.59 +        string = [pasteboard stringForType:format];
    1.60 +        if (string == nil) {
    1.61 +            utf8 = "";
    1.62          } else {
    1.63 -            text = SDL_strdup("");
    1.64 +            utf8 = [string UTF8String];
    1.65          }
    1.66 +        text = SDL_strdup(utf8);
    1.67 +    } else {
    1.68 +        text = SDL_strdup("");
    1.69      }
    1.70 -    
    1.71 +
    1.72 +    [pool release];
    1.73 +
    1.74      return text;
    1.75  }
    1.76  
    1.77 @@ -103,19 +108,22 @@
    1.78  void
    1.79  Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
    1.80  {
    1.81 +    NSAutoreleasePool *pool;
    1.82      NSPasteboard *pasteboard;
    1.83      NSInteger count;
    1.84  
    1.85 -    @autoreleasepool {
    1.86 -        pasteboard = [NSPasteboard generalPasteboard];
    1.87 -        count = [pasteboard changeCount];
    1.88 -        if (count != data->clipboard_count) {
    1.89 -            if (data->clipboard_count) {
    1.90 -                SDL_SendClipboardUpdate();
    1.91 -            }
    1.92 -            data->clipboard_count = count;
    1.93 +    pool = [[NSAutoreleasePool alloc] init];
    1.94 +
    1.95 +    pasteboard = [NSPasteboard generalPasteboard];
    1.96 +    count = [pasteboard changeCount];
    1.97 +    if (count != data->clipboard_count) {
    1.98 +        if (data->clipboard_count) {
    1.99 +            SDL_SendClipboardUpdate();
   1.100          }
   1.101 +        data->clipboard_count = count;
   1.102      }
   1.103 +
   1.104 +    [pool release];
   1.105  }
   1.106  
   1.107  #endif /* SDL_VIDEO_DRIVER_COCOA */