diff --git a/ChangeLog b/ChangeLog index 8f90a965b..66bfffbf0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-03-17 Richard Frith-Macdonald + + * Source/NSThread.m: Revise scheme for deallocation of thread + dictionary ... keep it operating to avoid problems with stuff + trying to use it while deing deallocated. Log memory leaks. + 2001-03-16 Nicola Pero * Source/Makefile.postamble (after-install): Removed old diff --git a/Headers/gnustep/base/NSThread.h b/Headers/gnustep/base/NSThread.h index 8b62dad8a..0e31eac72 100644 --- a/Headers/gnustep/base/NSThread.h +++ b/Headers/gnustep/base/NSThread.h @@ -44,7 +44,6 @@ typedef enum id _arg; SEL _selector; BOOL _active; - BOOL _deallocating; @public NSHandler *_exception_handler; NSMutableDictionary *_thread_dictionary; diff --git a/Source/NSThread.m b/Source/NSThread.m index a4bf74062..f22d489c9 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -329,12 +329,26 @@ gnustep_base_thread_callback() [NSException raise: NSInternalInconsistencyException format: @"Deallocating an active thread without [+exit]!"]; } - _deallocating = YES; DESTROY(_thread_dictionary); DESTROY(_target); DESTROY(_arg); [NSAutoreleasePool _endThread: self]; + if (_thread_dictionary != nil) + { + /* + * Try again to get rid of thread dictionary. + */ + init_autorelease_thread_vars(&_autorelease_vars); + DESTROY(_thread_dictionary); + [NSAutoreleasePool _endThread: self]; + if (_thread_dictionary != nil) + { + init_autorelease_thread_vars(&_autorelease_vars); + NSLog(@"Oops - leak - thread dictionary is %@", _thread_dictionary); + [NSAutoreleasePool _endThread: self]; + } + } NSDeallocateObject(self); } @@ -395,7 +409,7 @@ gnustep_base_thread_callback() */ - (NSMutableDictionary*) threadDictionary { - if (_thread_dictionary == nil && _deallocating == NO) + if (_thread_dictionary == nil) { _thread_dictionary = [NSMutableDictionary new]; }