From 52d70b9d02e5408cf8978f68cf778faee0e920bd Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Wed, 27 Feb 2002 09:40:22 +0000 Subject: [PATCH] [graphicsContextWithAttributes] always autorelease the context. Moved the unsetting of the current context from [dealloc] to [destroyContext] otherwise the current context can never be freed. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12813 72102866-910b-0410-8b05-ffd578937521 --- Source/NSGraphicsContext.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index 0a122082e..090be5c43 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -153,11 +153,11 @@ NSGraphicsContext *GSCurrentContext() @"Internal Error: No default NSGraphicsContext set\n"); ctxt = [[defaultNSGraphicsContextClass allocWithZone: _globalGSZone] initWithContextInfo: attributes]; - AUTORELEASE(ctxt); } else ctxt = [[self allocWithZone: _globalGSZone] initWithContextInfo: attributes]; - return ctxt; + + return AUTORELEASE(ctxt); } + (NSGraphicsContext *) graphicsContextWithWindow: (NSWindow *)aWindow @@ -182,8 +182,6 @@ NSGraphicsContext *GSCurrentContext() - (void) dealloc { - if (GSCurrentContext() == self) - [NSGraphicsContext setCurrentContext: nil]; DESTROY(focus_stack); DESTROY(context_data); DESTROY(context_info); @@ -196,6 +194,8 @@ NSGraphicsContext *GSCurrentContext() the next autorelease pool end */ - (void) destroyContext { + if (GSCurrentContext() == self) + [NSGraphicsContext setCurrentContext: nil]; [contextLock lock]; [contextList removeObject: self]; [contextLock unlock];