[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
This commit is contained in:
Fred Kiefer 2002-02-27 09:40:22 +00:00
parent bbe77d04d6
commit b9f9ae3f20

View file

@ -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];