mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 05:20:48 +00:00
[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:
parent
bbe77d04d6
commit
b9f9ae3f20
1 changed files with 4 additions and 4 deletions
|
@ -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];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue