diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 4c933ab8f1..8783ef4f1c 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -98,15 +98,14 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) // available. const NSOpenGLPixelFormatAttribute attrsAccel[] = { NSOpenGLPFAAccelerated, 0 }; - WXGLPixelFormat testFormat = [NSOpenGLPixelFormat alloc]; - if ( [testFormat initWithAttributes: attrsAccel] ) + if ( WXGLPixelFormat testFormat = [[NSOpenGLPixelFormat alloc] + initWithAttributes: attrsAccel] ) { // Hardware acceleration is available, use it. data[p++] = NSOpenGLPFAAccelerated; + [testFormat release]; } - [testFormat release]; - const NSOpenGLPixelFormatAttribute *attribs; if ( !attribList ) {