--- gnustep-base/Source/NSConnection.m 2006-03-08 12:28:59.000000000 +0100 +++ gnustep-base/Source/NSConnection.m 2006-08-14 13:09:53.000000000 +0200 @@ -3613,6 +3613,7 @@ * On thread exit, we need all connections to be removed from the runloop * of the thread or they will retain that and cause a memory leak. */ +#if 0 + (void) _threadWillExit: (NSNotification*)notification { NSRunLoop *runLoop = GSRunLoopForThread([notification object]); @@ -3632,6 +3633,36 @@ M_UNLOCK(connection_table_gate); } } +#else ++ (void) _threadWillExit: (NSNotification*)notification +{ + NSRunLoop *runLoop = GSRunLoopForThread ([notification object]); + + if (runLoop != nil) + { + NSMutableArray *connectionArray = [[NSMutableArray alloc] init]; + NSHashEnumerator enumerator; + NSEnumerator *num; + NSConnection *c; + M_LOCK (connection_table_gate); + enumerator = NSEnumerateHashTable (connection_table); + while ((c = (NSConnection*) NSNextHashEnumeratorItem (&enumerator)) != nil) + { + [connectionArray addObject: c]; + } + NSEndHashTableEnumeration (&enumerator); + M_UNLOCK (connection_table_gate); + + num = [connectionArray objectEnumerator]; + while ((c = [num nextObject])) + { + [c removeRunLoop: runLoop]; + } + + DESTROY (connectionArray); + } +} +#endif @end