Override -hash and -isEqual: so that notifications with the name name, object, and userInfo are considered equal. This is the OSX behavior.

This commit is contained in:
Richard Frith-Macdonald 2020-04-21 09:16:53 +01:00
parent ccfb05525e
commit a9767cdff7
2 changed files with 27 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2020-04-21 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSNotification.m:
Override -hash and -isEqual: so that notifications with the name name,
object, and userInfo are considered equal. This is the OSX behavior.
2020-04-14 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/GNUstepBase/GSConfig.h.in:

View file

@ -110,6 +110,11 @@ static Class concreteClass = 0;
[self name], [self object], [self userInfo]];
}
- (NSUInteger) hash
{
return [[self name] hash] ^ [[self object] hash];
}
- (id) init
{
if ([self class] == abstractClass)
@ -122,6 +127,22 @@ static Class concreteClass = 0;
return self;
}
- (BOOL) isEqual: (id)other
{
NSNotification *o;
NSObject *v1;
NSObject *v2;
if (NO == [(o = other) isKindOfClass: [NSNotification class]]
|| ((v1 = [self name]) != (v2 = [o name]) && ![v1 isEqual: v2])
|| ((v1 = [self object]) != (v2 = [o object]) && ![v1 isEqual: v2])
|| ((v1 = [self userInfo]) != (v2 = [o userInfo]) && ![v1 isEqual: v2]))
{
return NO;
}
return YES;
}
/**
* Returns the notification name.
*/