mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Make sure the static variable windowmaps is always initialized before
using it. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28311 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
039f0c39b0
commit
4aa1fb4c5e
2 changed files with 34 additions and 25 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-05-31 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSDisplayServer.m (+initialize,
|
||||
-_setWindowOwnedByServer:(), -dealloc): Set the windowmaps
|
||||
variable in the initialize method and protect all usages.
|
||||
|
||||
2009-05-23 22:17-EDT Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSWorkspace.m: Improve handling of CFBundleType...
|
||||
|
|
|
@ -72,6 +72,7 @@ GSDisplayServer *
|
|||
GSServerForWindow(NSWindow *window)
|
||||
{
|
||||
int num;
|
||||
|
||||
if (windowmaps == NULL)
|
||||
{
|
||||
NSLog(@"GSServerForWindow: No window server");
|
||||
|
@ -126,12 +127,14 @@ GSCurrentServer(void)
|
|||
{
|
||||
[gnustep_global_lock lock];
|
||||
if (serverLock == nil)
|
||||
{
|
||||
serverLock = [NSRecursiveLock new];
|
||||
_globalGSZone = NSDefaultMallocZone();
|
||||
defaultServerClass = [GSDisplayServer class];
|
||||
NSCurrentServerThreadKey = @"NSCurrentServerThreadKey";
|
||||
}
|
||||
{
|
||||
serverLock = [NSRecursiveLock new];
|
||||
_globalGSZone = NSDefaultMallocZone();
|
||||
defaultServerClass = [GSDisplayServer class];
|
||||
NSCurrentServerThreadKey = @"NSCurrentServerThreadKey";
|
||||
windowmaps = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 20);
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
}
|
||||
}
|
||||
|
@ -176,12 +179,6 @@ GSCurrentServer(void)
|
|||
{
|
||||
GSDisplayServer *server;
|
||||
|
||||
if (windowmaps == NULL)
|
||||
{
|
||||
windowmaps = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
|
||||
NSNonOwnedPointerMapValueCallBacks, 20);
|
||||
}
|
||||
|
||||
if (self == [GSDisplayServer class])
|
||||
{
|
||||
server = [[defaultServerClass allocWithZone: _globalGSZone]
|
||||
|
@ -251,20 +248,23 @@ GSCurrentServer(void)
|
|||
void *key;
|
||||
void *val;
|
||||
|
||||
/*
|
||||
* Remove the display server from the windows map.
|
||||
* This depends on a property of GNUstep map tables, that an
|
||||
* enumerated object can safely be removed from the map.
|
||||
*/
|
||||
enumerator = NSEnumerateMapTable(windowmaps);
|
||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &val))
|
||||
if (windowmaps != NULL)
|
||||
{
|
||||
if (val == (void*)self)
|
||||
{
|
||||
NSMapRemove(windowmaps, key);
|
||||
}
|
||||
/*
|
||||
* Remove the display server from the windows map.
|
||||
* This depends on a property of GNUstep map tables, that an
|
||||
* enumerated object can safely be removed from the map.
|
||||
*/
|
||||
enumerator = NSEnumerateMapTable(windowmaps);
|
||||
while (NSNextMapEnumeratorPair(&enumerator, &key, &val))
|
||||
{
|
||||
if (val == (void*)self)
|
||||
{
|
||||
NSMapRemove(windowmaps, key);
|
||||
}
|
||||
}
|
||||
NSEndMapTableEnumeration(&enumerator);
|
||||
}
|
||||
NSEndMapTableEnumeration(&enumerator);
|
||||
|
||||
DESTROY(server_info);
|
||||
DESTROY(event_queue);
|
||||
|
@ -517,7 +517,10 @@ GSCurrentServer(void)
|
|||
for a window that has already been created */
|
||||
- (void) _setWindowOwnedByServer: (int)win
|
||||
{
|
||||
NSMapInsert (windowmaps, (void*)(intptr_t)win, self);
|
||||
if (windowmaps != NULL)
|
||||
{
|
||||
NSMapInsert(windowmaps, (void*)(intptr_t)win, self);
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a window whose location and size is described by frame and
|
||||
|
|
Loading…
Reference in a new issue