Don't use deprecated +leak: method.

This commit is contained in:
rfm 2024-11-14 14:56:28 +00:00
parent 25505b2e67
commit 8b0543571b
4 changed files with 30 additions and 17 deletions

View file

@ -222,7 +222,8 @@ GSDomainFromDefaultLocale(void)
*/
if (saved == nil)
{
saved = [NSObject leak: dict];
saved = [dict copy];
[NSObject leaked: &saved];
}
/**

View file

@ -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.<br />
* The <code>NSLocalNotificationCenterType</code> 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
{

View file

@ -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