Thread bug fix for jigs.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13584 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-05-03 10:00:53 +00:00
parent e1f18282b7
commit b0e0eb482d
2 changed files with 26 additions and 7 deletions

View file

@ -8,6 +8,8 @@
are unable to determine the current thread. Don't attempt to use
NSLog() or similar ... since chances are, without a thread object,
that would just crash.
In GSRegisterCurrentThread(), add code to handle the case where the
NSThread class has not been initialised.
2002-05-02 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -479,17 +479,34 @@ GSRegisterCurrentThread (void)
*/
objc_thread_add ();
/*
* Create the new thread object.
*/
thread = (NSThread*)NSAllocateObject (threadClass, 0,
if (threadClass == 0)
{
/*
* If the threadClass has not been set, NSThread has not been
* initialised, and there is no default thread. So we must
* initialise now ... which will make the current thread the default.
*/
NSCAssert(entered_multi_threaded_state == NO,
NSInternalInconsistencyException);
thread = [NSThread currentThread];
}
else
{
/*
* Create the new thread object.
*/
thread = (NSThread*)NSAllocateObject (threadClass, 0,
NSDefaultMallocZone ());
thread = [thread _initWithSelector: NULL toTarget: nil withObject: nil];
objc_thread_set_data (thread);
((NSThread_ivars *)thread)->_active = YES;
thread = [thread _initWithSelector: NULL toTarget: nil withObject: nil];
objc_thread_set_data (thread);
((NSThread_ivars *)thread)->_active = YES;
}
/*
* We post the notification after we register the thread.
* NB. Even if we are the default thread, we do this to register the app
* as being multi-threaded - this is so that, if this thread is unregistered
* later, it does not leave us with a bad default thread.
*/
gnustep_base_thread_callback();