From bc3d2508ee77333edcb2cbea20bcf324612c64fe Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 2 Jan 2025 17:43:28 +0000 Subject: [PATCH] Avoid use of NSDeallocateObject() as it dooesn't work properly with new runtime. --- Source/NSConnection.m | 10 +++------- Source/NSMessagePort.m | 16 ++++------------ Source/NSSocketPort.m | 11 +++-------- Source/win32/NSMessagePort.m | 10 +++------- 4 files changed, 13 insertions(+), 34 deletions(-) diff --git a/Source/NSConnection.m b/Source/NSConnection.m index fac103e8e1..89ca8fc8b4 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -1467,16 +1467,12 @@ - (oneway void) release * and try to use it while it is being deallocated. */ GS_M_LOCK(connection_table_gate); - if (NSDecrementExtraRefCountWasZero(self)) + if (1 == [self retainCount]) { NSHashRemove(connection_table, self); - GSM_UNLOCK(connection_table_gate); - [self dealloc]; - } - else - { - GSM_UNLOCK(connection_table_gate); } + GSM_UNLOCK(connection_table_gate); + [super release]; } /** diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index bc055c25a4..7eb5e6e406 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -1699,20 +1699,12 @@ - (void) receivedEvent: (void*)data - (oneway void) release { M_LOCK(messagePortLock); - if (NSDecrementExtraRefCountWasZero(self)) + if (_internal != 0 && 1 == [self retainCount]) { - if (_internal != 0) - { - NSMapRemove(messagePortMap, (void*)name); - } - [self retain]; - M_UNLOCK(messagePortLock); - [super release]; - } - else - { - M_UNLOCK(messagePortLock); + NSMapRemove(messagePortMap, (void*)name); } + M_UNLOCK(messagePortLock); + [super release]; } - (void) removeHandle: (GSMessageHandle*)handle diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index 603637c86c..016c998169 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -2465,7 +2465,7 @@ - (void) receivedEvent: (void*)data - (oneway void) release { M_LOCK(tcpPortLock); - if (NSDecrementExtraRefCountWasZero(self)) + if (1 == [self retainCount]) { NSMapTable *thePorts; @@ -2474,14 +2474,9 @@ - (oneway void) release { NSMapRemove(thePorts, host); } - [self retain]; - M_UNLOCK(tcpPortLock); - [super release]; - } - else - { - M_UNLOCK(tcpPortLock); } + M_UNLOCK(tcpPortLock); + [super release]; } diff --git a/Source/win32/NSMessagePort.m b/Source/win32/NSMessagePort.m index a0123b77a8..571d187a8f 100644 --- a/Source/win32/NSMessagePort.m +++ b/Source/win32/NSMessagePort.m @@ -949,16 +949,12 @@ - (oneway void) release * and try to use it while it is being deallocated. */ M_LOCK(messagePortLock); - if (NSDecrementExtraRefCountWasZero(self)) + if (1 == [self retainCount]) { NSMapRemove(ports, (void*)[self name]); - M_UNLOCK(messagePortLock); - [self dealloc]; - } - else - { - M_UNLOCK(messagePortLock); } + M_UNLOCK(messagePortLock); + [super release]; } - (BOOL) sendBeforeDate: (NSDate*)when