Skip to content

Commit

Permalink
Fixes for tests with weak pointers in notification observers.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Dec 27, 2024
1 parent f6d47ba commit 40bae20
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
* Source/GSPrivate.h:
* Source/NSConcreteHashTable.m:
* Source/NSConcretePointerFunctions.h:
* Source/NSMessagePort.m:
* Source/NSNotificationCenter.m:
* Source/NSObject.m:
* Source/NSSocketPort.m:
* Source/ObjectiveC2/GNUmakefile:
* Source/ObjectiveC2/README:
* Source/ObjectiveC2/weak.m:
Expand Down
3 changes: 2 additions & 1 deletion Source/NSMessagePort.m
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,9 @@ - (oneway void) release
{
NSMapRemove(messagePortMap, (void*)name);
}
[self retain];
M_UNLOCK(messagePortLock);
[self dealloc];
[super release];
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions Source/NSObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,10 @@ - (Class) originalClass
}
return c;
}
- (NSUInteger) retainCount
{
return 0; // So that gs_weak_load() knows the object was deallocated
}
- (void) logZombie: (SEL)selector
{
GSLogZombie(self, selector);
Expand Down
3 changes: 2 additions & 1 deletion Source/NSSocketPort.m
Original file line number Diff line number Diff line change
Expand Up @@ -2474,8 +2474,9 @@ - (oneway void) release
{
NSMapRemove(thePorts, host);
}
[self retain];
M_UNLOCK(tcpPortLock);
[self dealloc];
[super release];
}
else
{
Expand Down
9 changes: 5 additions & 4 deletions Tests/base/NSConnection/basic.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
id testObject = nil;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
id testObject = nil;

test_alloc(@"NSConnection");
testObject = [NSConnection new];
test_NSObject(@"NSConnection",[NSArray arrayWithObject:testObject]);
test_NSObject(@"NSConnection", [NSArray arrayWithObject: testObject]);
testObject = [NSConnection defaultConnection];
PASS(testObject != nil && [testObject isKindOfClass:[NSConnection class]],
PASS(testObject != nil && [testObject isKindOfClass: [NSConnection class]],
"NSConnection +defaultConnection works");

[arp release]; arp = nil;
Expand Down

0 comments on commit 40bae20

Please sign in to comment.