Replaced all remaining uses of NSAutoreleasePool with @autoreleasepool blocks (bugzilla #2680.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m
index 0bbbbcb..02441ef 100644
--- a/src/video/cocoa/SDL_cocoaopengl.m
+++ b/src/video/cocoa/SDL_cocoaopengl.m
@@ -150,8 +150,8 @@ Cocoa_GL_UnloadLibrary(_THIS)
SDL_GLContext
Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
@@ -173,8 +173,6 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
return NULL;
}
- pool = [[NSAutoreleasePool alloc] init];
-
/* specify a profile if we're on Lion (10.7) or later. */
if (lion_or_later) {
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
@@ -239,7 +237,6 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if (fmt == nil) {
SDL_SetError("Failed creating OpenGL pixel format");
- [pool release];
return NULL;
}
@@ -253,12 +250,9 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
if (context == nil) {
SDL_SetError("Failed creating OpenGL context");
- [pool release];
return NULL;
}
- [pool release];
-
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
Cocoa_GL_DeleteContext(_this, context);
SDL_SetError("Failed making OpenGL context current");
@@ -306,15 +300,12 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
/*_this->gl_config.minor_version = glversion_minor;*/
}
return context;
-}
+}}
int
Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
-
- pool = [[NSAutoreleasePool alloc] init];
-
if (context) {
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
[nscontext setWindow:window];
@@ -324,9 +315,8 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
[NSOpenGLContext clearCurrentContext];
}
- [pool release];
return 0;
-}
+}}
void
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
@@ -352,8 +342,8 @@ Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
int
Cocoa_GL_SetSwapInterval(_THIS, int interval)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
NSOpenGLContext *nscontext;
GLint value;
int status;
@@ -362,8 +352,6 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
return SDL_SetError("Late swap tearing currently unsupported");
}
- pool = [[NSAutoreleasePool alloc] init];
-
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
if (nscontext != nil) {
value = interval;
@@ -373,57 +361,44 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
status = SDL_SetError("No current OpenGL context");
}
- [pool release];
return status;
-}
+}}
int
Cocoa_GL_GetSwapInterval(_THIS)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
NSOpenGLContext *nscontext;
GLint value;
int status = 0;
- pool = [[NSAutoreleasePool alloc] init];
-
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
if (nscontext != nil) {
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
status = (int)value;
}
- [pool release];
return status;
-}
+}}
void
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
-
- pool = [[NSAutoreleasePool alloc] init];
-
SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
[nscontext flushBuffer];
[nscontext updateIfNeeded];
-
- [pool release];
-}
+}}
void
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
- pool = [[NSAutoreleasePool alloc] init];
-
[nscontext setWindow:NULL];
[nscontext release];
-
- [pool release];
-}
+}}
#endif /* SDL_VIDEO_OPENGL_CGL */
diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m
index 61d800b..ddba14b 100644
--- a/src/video/cocoa/SDL_cocoashape.m
+++ b/src/video/cocoa/SDL_cocoashape.m
@@ -75,11 +75,11 @@ ConvertRects(SDL_ShapeTree* tree, void* closure)
int
Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
+{ @autoreleasepool
{
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
SDL_CocoaClosure closure;
- NSAutoreleasePool *pool = NULL;
if(data->saved == SDL_TRUE) {
[data->context restoreGraphicsState];
data->saved = SDL_FALSE;
@@ -93,16 +93,14 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
NSRectFill([[windata->nswindow contentView] frame]);
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
- pool = [[NSAutoreleasePool alloc] init];
closure.view = [windata->nswindow contentView];
closure.path = [NSBezierPath bezierPath];
closure.window = shaper->window;
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
[closure.path addClip];
- [pool release];
return 0;
-}
+}}
int
Cocoa_ResizeWindowShape(SDL_Window *window)
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 2d301e4..c44284f 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1000,8 +1000,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
static int
SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data;
@@ -1016,8 +1016,6 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
data->videodata = videodata;
data->nscontexts = [[NSMutableArray alloc] init];
- pool = [[NSAutoreleasePool alloc] init];
-
/* Create an event listener for the window */
data->listener = [[Cocoa_WindowListener alloc] init];
@@ -1079,16 +1077,15 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
[nswindow setOneShot:NO];
/* All done! */
- [pool release];
window->driverdata = data;
return 0;
-}
+}}
int
Cocoa_CreateWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *nswindow;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
NSRect rect;
@@ -1123,9 +1120,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen];
}
@catch (NSException *e) {
- SDL_SetError("%s", [[e reason] UTF8String]);
- [pool release];
- return -1;
+ return SDL_SetError("%s", [[e reason] UTF8String]);
}
[nswindow setBackgroundColor:[NSColor blackColor]];
@@ -1155,63 +1150,54 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
/* Allow files and folders to be dragged onto the window by users */
[nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
- [pool release];
-
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
[nswindow release];
return -1;
}
return 0;
-}
+}}
int
Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool;
NSWindow *nswindow = (NSWindow *) data;
NSString *title;
- pool = [[NSAutoreleasePool alloc] init];
-
/* Query the title from the existing window */
title = [nswindow title];
if (title) {
window->title = SDL_strdup([title UTF8String]);
}
- [pool release];
-
return SetupWindowData(_this, window, nswindow, SDL_FALSE);
-}
+}}
void
Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
NSString *string = [[NSString alloc] initWithUTF8String:window->title];
[nswindow setTitle:string];
[string release];
- [pool release];
-}
+}}
void
Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSImage *nsimage = Cocoa_CreateImage(icon);
if (nsimage) {
[NSApp setApplicationIconImage:nsimage];
}
-
- [pool release];
-}
+}}
void
Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = windata->nswindow;
NSRect rect;
@@ -1229,14 +1215,12 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
s_moveHack = moveHack;
ScheduleContextUpdates(windata);
-
- [pool release];
-}
+}}
void
Cocoa_SetWindowSize(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = windata->nswindow;
NSSize size;
@@ -1246,14 +1230,12 @@ Cocoa_SetWindowSize(_THIS, SDL_Window * window)
[nswindow setContentSize:size];
ScheduleContextUpdates(windata);
-
- [pool release];
-}
+}}
void
Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSSize minSize;
@@ -1261,14 +1243,12 @@ Cocoa_SetWindowMinimumSize(_THIS, SDL_Window * window)
minSize.height = window->min_h;
[windata->nswindow setContentMinSize:minSize];
-
- [pool release];
-}
+}}
void
Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSSize maxSize;
@@ -1276,14 +1256,12 @@ Cocoa_SetWindowMaximumSize(_THIS, SDL_Window * window)
maxSize.height = window->max_h;
[windata->nswindow setContentMaxSize:maxSize];
-
- [pool release];
-}
+}}
void
Cocoa_ShowWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
NSWindow *nswindow = windowData->nswindow;
@@ -1292,23 +1270,21 @@ Cocoa_ShowWindow(_THIS, SDL_Window * window)
[nswindow makeKeyAndOrderFront:nil];
[windowData->listener resumeVisibleObservation];
}
- [pool release];
-}
+}}
void
Cocoa_HideWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
[nswindow orderOut:nil];
- [pool release];
-}
+}}
void
Cocoa_RaiseWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
NSWindow *nswindow = windowData->nswindow;
@@ -1321,28 +1297,24 @@ Cocoa_RaiseWindow(_THIS, SDL_Window * window)
[nswindow makeKeyAndOrderFront:nil];
}
[windowData->listener resumeVisibleObservation];
-
- [pool release];
-}
+}}
void
Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = windata->nswindow;
[nswindow zoom:nil];
ScheduleContextUpdates(windata);
-
- [pool release];
-}
+}}
void
Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = data->nswindow;
@@ -1351,13 +1323,12 @@ Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
} else {
[nswindow miniaturize:nil];
}
- [pool release];
-}
+}}
void
Cocoa_RestoreWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
if ([nswindow isMiniaturized]) {
@@ -1365,8 +1336,7 @@ Cocoa_RestoreWindow(_THIS, SDL_Window * window)
} else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
[nswindow zoom:nil];
}
- [pool release];
-}
+}}
static NSWindow *
Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
@@ -1391,21 +1361,20 @@ Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
void
Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (SetWindowStyle(window, GetWindowStyle(window))) {
if (bordered) {
Cocoa_SetWindowTitle(_this, window); /* this got blanked out. */
}
}
- [pool release];
-}
+}}
void
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = data->nswindow;
NSRect rect;
@@ -1479,9 +1448,7 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
}
ScheduleContextUpdates(data);
-
- [pool release];
-}
+}}
int
Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
@@ -1564,8 +1531,8 @@ Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
void
Cocoa_DestroyWindow(_THIS, SDL_Window * window)
+{ @autoreleasepool
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (data) {
@@ -1585,9 +1552,7 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
SDL_free(data);
}
window->driverdata = NULL;
-
- [pool release];
-}
+}}
SDL_bool
Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
@@ -1619,9 +1584,9 @@ Cocoa_IsWindowInFullscreenSpace(SDL_Window * window)
SDL_bool
Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
+{ @autoreleasepool
{
SDL_bool succeeded = SDL_FALSE;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
@@ -1642,10 +1607,8 @@ Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
}
}
- [pool release];
-
return succeeded;
-}
+}}
int
Cocoa_SetWindowHitTest(SDL_Window * window, SDL_bool enabled)