1.1 --- a/src/video/cocoa/SDL_cocoaclipboard.m Fri Feb 01 17:09:01 2013 -0800
1.2 +++ b/src/video/cocoa/SDL_cocoaclipboard.m Sun Jan 06 19:04:53 2013 +0300
1.3 @@ -45,51 +45,46 @@
1.4 Cocoa_SetClipboardText(_THIS, const char *text)
1.5 {
1.6 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
1.7 - NSAutoreleasePool *pool;
1.8 +
1.9 NSPasteboard *pasteboard;
1.10 NSString *format = GetTextFormat(_this);
1.11
1.12 - pool = [[NSAutoreleasePool alloc] init];
1.13 -
1.14 - pasteboard = [NSPasteboard generalPasteboard];
1.15 - data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
1.16 - [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
1.17 -
1.18 - [pool release];
1.19 -
1.20 + @autoreleasepool {
1.21 + pasteboard = [NSPasteboard generalPasteboard];
1.22 + data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
1.23 + [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
1.24 + }
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 - pool = [[NSAutoreleasePool alloc] init];
1.39 -
1.40 - pasteboard = [NSPasteboard generalPasteboard];
1.41 - available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
1.42 - if ([available isEqualToString:format]) {
1.43 - NSString* string;
1.44 - const char *utf8;
1.45 + @autoreleasepool {
1.46 + pasteboard = [NSPasteboard generalPasteboard];
1.47 + available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
1.48 + if ([available isEqualToString:format]) {
1.49 + NSString* string;
1.50 + const char *utf8;
1.51
1.52 - string = [pasteboard stringForType:format];
1.53 - if (string == nil) {
1.54 - utf8 = "";
1.55 + string = [pasteboard stringForType:format];
1.56 + if (string == nil) {
1.57 + utf8 = "";
1.58 + } else {
1.59 + utf8 = [string UTF8String];
1.60 + }
1.61 + text = SDL_strdup(utf8);
1.62 } else {
1.63 - utf8 = [string UTF8String];
1.64 + text = SDL_strdup("");
1.65 }
1.66 - text = SDL_strdup(utf8);
1.67 - } else {
1.68 - text = SDL_strdup("");
1.69 }
1.70 -
1.71 - [pool release];
1.72 -
1.73 +
1.74 return text;
1.75 }
1.76
1.77 @@ -108,22 +103,19 @@
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 - pool = [[NSAutoreleasePool alloc] init];
1.86 -
1.87 - pasteboard = [NSPasteboard generalPasteboard];
1.88 - count = [pasteboard changeCount];
1.89 - if (count != data->clipboard_count) {
1.90 - if (data->clipboard_count) {
1.91 - SDL_SendClipboardUpdate();
1.92 + @autoreleasepool {
1.93 + pasteboard = [NSPasteboard generalPasteboard];
1.94 + count = [pasteboard changeCount];
1.95 + if (count != data->clipboard_count) {
1.96 + if (data->clipboard_count) {
1.97 + SDL_SendClipboardUpdate();
1.98 + }
1.99 + data->clipboard_count = count;
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 */