git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36489 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-04-08 08:33:12 +00:00
parent 0c977df4a7
commit d7d31502ec
2 changed files with 36 additions and 14 deletions

View file

@ -1,3 +1,7 @@
2013-04-08 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSNotificationCenter.m: Fix bug #38680
2013-04-05 Richard Frith-Macdonald <rfm@gnu.org> 2013-04-05 Richard Frith-Macdonald <rfm@gnu.org>
* config/pathtls.m4: Try to guess gnutls flags if no config found * config/pathtls.m4: Try to guess gnutls flags if no config found

View file

@ -86,7 +86,7 @@ static Class concrete = 0;
{ {
return [self retain]; return [self retain];
} }
n = (GSNotification*)NSAllocateObject(concrete, 0, NSDefaultMallocZone()); n = (GSNotification*)NSAllocateObject(concrete, 0, zone);
n->_name = [_name copyWithZone: [self zone]]; n->_name = [_name copyWithZone: [self zone]];
n->_object = TEST_RETAIN(_object); n->_object = TEST_RETAIN(_object);
n->_info = TEST_RETAIN(_info); n->_info = TEST_RETAIN(_info);
@ -795,7 +795,9 @@ static NSNotificationCenter *default_center = nil;
name: (NSString*)name name: (NSString*)name
object: (id)object object: (id)object
{ {
IMP method; Class cls;
Method method;
IMP imp;
Observation *list; Observation *list;
Observation *o; Observation *o;
GSIMapTable m; GSIMapTable m;
@ -809,20 +811,28 @@ static NSNotificationCenter *default_center = nil;
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Null selector passed to addObserver ..."]; format: @"Null selector passed to addObserver ..."];
#if defined(DEBUG) cls = object_getClass(observer);
if ([observer respondsToSelector: selector] == NO) method = class_getInstanceMethod(cls, selector);
NSLog(@"Observer '%@' does not respond to selector '%@'", observer, imp = method_getImplementation(method);
NSStringFromSelector(selector)); if (0 == imp)
#endif {
/* A class may not implement the selector (in which case we can't
method = [observer methodForSelector: selector]; * cache the method), but if it's going to forward the message to
if (method == 0) * some other object it must at least say it responds to the
[NSException raise: NSInvalidArgumentException * selector.
format: @"Observer can not handle specified selector"]; */
if ([observer respondsToSelector: selector] == NO)
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-%@] Observer '%@' does not respond to selector '%@'",
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
observer, NSStringFromSelector(selector)];
}
}
lockNCTable(TABLE); lockNCTable(TABLE);
o = obsNew(TABLE, selector, method, observer); o = obsNew(TABLE, selector, imp, observer);
if (object != nil) if (object != nil)
{ {
@ -1221,7 +1231,15 @@ static NSNotificationCenter *default_center = nil;
{ {
NS_DURING NS_DURING
{ {
(*o->method)(o->observer, o->selector, notification); if (0 == o->method)
{
[o->observer performSelector: o->selector
withObject: notification];
}
else
{
(*o->method)(o->observer, o->selector, notification);
}
} }
NS_HANDLER NS_HANDLER
{ {