mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Catch autoreleased objects during thread exit.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22333 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
909f32bf87
commit
7a186a7782
4 changed files with 29 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2006-01-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Headers/Foundation/NSThread.h:
|
||||||
|
* Source/NSAutoreleasePool.m:
|
||||||
|
* Source/NSThread.m:
|
||||||
|
Mimic MacOS-X behavior and create an autorelease pool if necessary
|
||||||
|
to catch any autorelease objects during thread exit.
|
||||||
|
As suggested by Wim Oudshoorn..
|
||||||
|
|
||||||
2006-01-18 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-01-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/Additions/Unicode.m: fix for rare case where we could corrupt
|
* Source/Additions/Unicode.m: fix for rare case where we could corrupt
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
id _target;
|
id _target;
|
||||||
id _arg;
|
id _arg;
|
||||||
SEL _selector;
|
SEL _selector;
|
||||||
BOOL _active;
|
|
||||||
@public
|
@public
|
||||||
|
BOOL _active;
|
||||||
NSHandler *_exception_handler;
|
NSHandler *_exception_handler;
|
||||||
NSMutableDictionary *_thread_dictionary;
|
NSMutableDictionary *_thread_dictionary;
|
||||||
struct autorelease_thread_vars _autorelease_vars;
|
struct autorelease_thread_vars _autorelease_vars;
|
||||||
|
|
|
@ -228,8 +228,14 @@ static IMP initImp;
|
||||||
|
|
||||||
+ (void) addObject: (id)anObj
|
+ (void) addObject: (id)anObj
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = ARP_THREAD_VARS->current_pool;
|
NSThread *t = GSCurrentThread();
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
|
|
||||||
|
if (t->_active == NO)
|
||||||
|
{
|
||||||
|
[self new]; // Don't leak while exiting thread.
|
||||||
|
}
|
||||||
|
pool = t->_autorelease_vars.current_pool;
|
||||||
if (pool != nil)
|
if (pool != nil)
|
||||||
{
|
{
|
||||||
(*pool->_addImp)(pool, @selector(addObject:), anObj);
|
(*pool->_addImp)(pool, @selector(addObject:), anObj);
|
||||||
|
|
|
@ -703,7 +703,10 @@ gnustep_base_thread_callback(void)
|
||||||
DESTROY(_thread_dictionary);
|
DESTROY(_thread_dictionary);
|
||||||
DESTROY(_target);
|
DESTROY(_target);
|
||||||
DESTROY(_arg);
|
DESTROY(_arg);
|
||||||
[NSAutoreleasePool _endThread: self];
|
if (_autorelease_vars.pool_cache != 0)
|
||||||
|
{
|
||||||
|
[NSAutoreleasePool _endThread: self];
|
||||||
|
}
|
||||||
|
|
||||||
if (_thread_dictionary != nil)
|
if (_thread_dictionary != nil)
|
||||||
{
|
{
|
||||||
|
@ -711,11 +714,17 @@ gnustep_base_thread_callback(void)
|
||||||
* Try again to get rid of thread dictionary.
|
* Try again to get rid of thread dictionary.
|
||||||
*/
|
*/
|
||||||
DESTROY(_thread_dictionary);
|
DESTROY(_thread_dictionary);
|
||||||
[NSAutoreleasePool _endThread: self];
|
if (_autorelease_vars.pool_cache != 0)
|
||||||
|
{
|
||||||
|
[NSAutoreleasePool _endThread: self];
|
||||||
|
}
|
||||||
if (_thread_dictionary != nil)
|
if (_thread_dictionary != nil)
|
||||||
{
|
{
|
||||||
NSLog(@"Oops - leak - thread dictionary is %@", _thread_dictionary);
|
NSLog(@"Oops - leak - thread dictionary is %@", _thread_dictionary);
|
||||||
[NSAutoreleasePool _endThread: self];
|
if (_autorelease_vars.pool_cache != 0)
|
||||||
|
{
|
||||||
|
[NSAutoreleasePool _endThread: self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self == defaultThread)
|
if (self == defaultThread)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue