diff --git a/Headers/GNUstepBase/NSObject+GNUstepBase.h b/Headers/GNUstepBase/NSObject+GNUstepBase.h
index bef4a5c74..150b5838f 100644
--- a/Headers/GNUstepBase/NSObject+GNUstepBase.h
+++ b/Headers/GNUstepBase/NSObject+GNUstepBase.h
@@ -251,7 +251,7 @@ extern "C" {
/** Deprecated: use +leaked: instead.
*/
-+ (id) NS_RETURNS_RETAINED leak: (id)anObject ;//GS_DEPRECATED_FUNC;
++ (id) NS_RETURNS_RETAINED leak: (id)anObject GS_DEPRECATED_FUNC;
/** Deprecated: use +leaked: instead.
*/
diff --git a/Source/GSLocale.m b/Source/GSLocale.m
index aacf68ff8..d52ab8c96 100644
--- a/Source/GSLocale.m
+++ b/Source/GSLocale.m
@@ -222,7 +222,8 @@ GSDomainFromDefaultLocale(void)
*/
if (saved == nil)
{
- saved = [NSObject leak: dict];
+ saved = [dict copy];
+ [NSObject leaked: &saved];
}
/**
diff --git a/Source/NSDistributedNotificationCenter.m b/Source/NSDistributedNotificationCenter.m
index e68d40493..c0d63f85c 100644
--- a/Source/NSDistributedNotificationCenter.m
+++ b/Source/NSDistributedNotificationCenter.m
@@ -114,6 +114,13 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
return nil;
}
++ (void) atExit
+{
+ DESTROY(locCenter);
+ DESTROY(pubCenter);
+ DESTROY(netCenter);
+}
+
/**
* Returns the default notification center ... a shared notification
* center for the local host. This is simply a convenience method
@@ -125,6 +132,11 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
return [self notificationCenterForType: NSLocalNotificationCenterType];
}
++ (void) initialize
+{
+ [self registerAtExit];
+}
+
/**
* Returns a notification center of the specified type.
* The NSLocalNotificationCenterType
provides a shared access to
@@ -144,7 +156,7 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
if (locCenter == nil)
{
GS_MUTEX_LOCK(classLock);
- if (locCenter == nil)
+ if (locCenter == nil && NO == [NSObject isExiting])
{
NS_DURING
{
@@ -154,8 +166,7 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
NSAllocateObject(self, 0, NSDefaultMallocZone());
tmp->_centerLock = [NSRecursiveLock new];
tmp->_type = RETAIN(NSLocalNotificationCenterType);
- locCenter = [NSObject leak: tmp];
- [tmp release];
+ locCenter = tmp;
}
NS_HANDLER
{
@@ -173,7 +184,7 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
if (pubCenter == nil)
{
GS_MUTEX_LOCK(classLock);
- if (pubCenter == nil)
+ if (pubCenter == nil && NO == [NSObject isExiting])
{
NS_DURING
{
@@ -183,8 +194,7 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
NSAllocateObject(self, 0, NSDefaultMallocZone());
tmp->_centerLock = [NSRecursiveLock new];
tmp->_type = RETAIN(GSPublicNotificationCenterType);
- pubCenter = [NSObject leak: tmp];
- [tmp release];
+ pubCenter = tmp;
}
NS_HANDLER
{
@@ -202,7 +212,7 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
if (netCenter == nil)
{
GS_MUTEX_LOCK(classLock);
- if (netCenter == nil)
+ if (netCenter == nil && NO == [NSObject isExiting])
{
NS_DURING
{
@@ -212,8 +222,7 @@ static gs_mutex_t classLock = GS_MUTEX_INIT_STATIC;
NSAllocateObject(self, 0, NSDefaultMallocZone());
tmp->_centerLock = [NSRecursiveLock new];
tmp->_type = RETAIN(GSNetworkNotificationCenterType);
- netCenter = [NSObject leak: tmp];
- [tmp release];
+ netCenter = tmp;
}
NS_HANDLER
{
diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m
index 297226e6b..9b13b5606 100644
--- a/Source/NSRunLoop.m
+++ b/Source/NSRunLoop.m
@@ -786,7 +786,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
NSTimer *timer;
SEL sel;
#ifdef RL_INTEGRATE_DISPATCH
- GSMainQueueDrainer *drain;
+ static GSMainQueueDrainer *drainer = nil;
#endif
ctr = [NSNotificationCenter defaultCenter];
@@ -810,17 +810,20 @@ static inline BOOL timerInvalidated(NSTimer *t)
[current addTimer: timer forMode: NSDefaultRunLoopMode];
#ifdef RL_INTEGRATE_DISPATCH
- /* We leak the queue drainer, because it's integral part of RL
- * operations
- */
- drain = [NSObject leak: [[GSMainQueueDrainer new] autorelease]];
+ if (nil == drainer)
+ {
+ /* We leak the queue drainer, because it's integral part of RL
+ * operations
+ */
+ drainer = [GSMainQueueDrainer new];
+ }
[current addEvent: [GSMainQueueDrainer mainQueueFileDescriptor]
#ifdef _WIN32
type: ET_HANDLE
#else
type: ET_RDESC
#endif
- watcher: drain
+ watcher: drainer
forMode: NSDefaultRunLoopMode];
#endif