Skip to content
Permalink
Browse files

Replaced all remaining uses of NSAutoreleasePool with @autoreleasepool

…blocks (bugzilla #2680.)
  • Loading branch information
slime73 committed May 5, 2015
1 parent 6c20b68 commit 4fc402666077b3a506d9ebb88f509968196a66c6
Showing with 53 additions and 117 deletions.
  1. +12 −37 src/video/cocoa/SDL_cocoaopengl.m
  2. +2 −4 src/video/cocoa/SDL_cocoashape.m
  3. +39 −76 src/video/cocoa/SDL_cocoawindow.m
@@ -150,8 +150,8 @@ - (void)setWindow:(SDL_Window *)newWindow

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 @@ - (void)setWindow:(SDL_Window *)newWindow
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 @@ - (void)setWindow:(SDL_Window *)newWindow
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if (fmt == nil) {
SDL_SetError("Failed creating OpenGL pixel format");
[pool release];
return NULL;
}

@@ -253,12 +250,9 @@ - (void)setWindow:(SDL_Window *)newWindow

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 @@ - (void)setWindow:(SDL_Window *)newWindow
/*_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 @@ - (void)setWindow:(SDL_Window *)newWindow
[NSOpenGLContext clearCurrentContext];
}

[pool release];
return 0;
}
}}

void
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
@@ -352,8 +342,8 @@ - (void)setWindow:(SDL_Window *)newWindow

int
Cocoa_GL_SetSwapInterval(_THIS, int interval)
{ @autoreleasepool
{
NSAutoreleasePool *pool;
NSOpenGLContext *nscontext;
GLint value;
int status;
@@ -362,8 +352,6 @@ - (void)setWindow:(SDL_Window *)newWindow
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 @@ - (void)setWindow:(SDL_Window *)newWindow
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 */

@@ -75,11 +75,11 @@

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 @@
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)

0 comments on commit 4fc4026

Please sign in to comment.