Skip to content

Commit

Permalink
Avoid use of NSDeallocateObject() as it dooesn't work properly with n…
Browse files Browse the repository at this point in the history
…ew runtime.
  • Loading branch information
rfm committed Jan 2, 2025
1 parent ae8367e commit bc3d250
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
10 changes: 3 additions & 7 deletions Source/NSConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

/**
Expand Down
16 changes: 4 additions & 12 deletions Source/NSMessagePort.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions Source/NSSocketPort.m
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,7 @@ - (void) receivedEvent: (void*)data
- (oneway void) release
{
M_LOCK(tcpPortLock);
if (NSDecrementExtraRefCountWasZero(self))
if (1 == [self retainCount])
{
NSMapTable *thePorts;

Expand All @@ -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];
}


Expand Down
10 changes: 3 additions & 7 deletions Source/win32/NSMessagePort.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc3d250

Please sign in to comment.