Minor bugfix patch

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-09-30 17:47:35 +00:00
parent ce828f5acf
commit d0315f7662
3 changed files with 33 additions and 2 deletions

View file

@ -33,6 +33,8 @@
#include "Foundation/NSLock.h"
#include "Foundation/NSPathUtilities.h"
#include "Foundation/NSDictionary.h"
#include "Foundation/NSThread.h"
#include "Foundation/NSNotification.h"
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
@ -43,6 +45,18 @@ static NSLock* cache_lock = nil;
@implementation NSCharacterSet
+ (void) _becomeThreaded: (NSNotification*)notification
{
if (cache_lock == nil)
{
cache_lock = [NSLock new];
[[NSNotificationCenter defaultCenter]
removeObserver: self
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
}
+ (void) initialize
{
static BOOL one_time = NO;
@ -57,6 +71,18 @@ static NSLock* cache_lock = nil;
}
one_time = YES;
}
if ([NSThread isMultiThreaded])
{
[self _becomeThreaded: nil];
}
else
{
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_becomeThreaded:)
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
}
/* Provide a default object for allocation */
@ -73,8 +99,6 @@ static NSLock* cache_lock = nil;
NSString *set_path;
NSBundle *bundle;
if (!cache_lock)
cache_lock = [NSLock new];
[cache_lock lock];
set = nil; /* Quiet warnings */