[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:
FredKiefer 2002-02-27 09:40:22 +00:00
parent 95c7931f6c
commit 52d70b9d02

View file

@ -153,11 +153,11 @@ NSGraphicsContext *GSCurrentContext()
@"Internal Error: No default NSGraphicsContext set\n"); @"Internal Error: No default NSGraphicsContext set\n");
ctxt = [[defaultNSGraphicsContextClass allocWithZone: _globalGSZone] ctxt = [[defaultNSGraphicsContextClass allocWithZone: _globalGSZone]
initWithContextInfo: attributes]; initWithContextInfo: attributes];
AUTORELEASE(ctxt);
} }
else else
ctxt = [[self allocWithZone: _globalGSZone] initWithContextInfo: attributes]; ctxt = [[self allocWithZone: _globalGSZone] initWithContextInfo: attributes];
return ctxt;
return AUTORELEASE(ctxt);
} }
+ (NSGraphicsContext *) graphicsContextWithWindow: (NSWindow *)aWindow + (NSGraphicsContext *) graphicsContextWithWindow: (NSWindow *)aWindow
@ -182,8 +182,6 @@ NSGraphicsContext *GSCurrentContext()
- (void) dealloc - (void) dealloc
{ {
if (GSCurrentContext() == self)
[NSGraphicsContext setCurrentContext: nil];
DESTROY(focus_stack); DESTROY(focus_stack);
DESTROY(context_data); DESTROY(context_data);
DESTROY(context_info); DESTROY(context_info);
@ -196,6 +194,8 @@ NSGraphicsContext *GSCurrentContext()
the next autorelease pool end */ the next autorelease pool end */
- (void) destroyContext - (void) destroyContext
{ {
if (GSCurrentContext() == self)
[NSGraphicsContext setCurrentContext: nil];
[contextLock lock]; [contextLock lock];
[contextList removeObject: self]; [contextList removeObject: self];
[contextLock unlock]; [contextLock unlock];