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);
method = class_getInstanceMethod(cls, selector);
imp = method_getImplementation(method);
if (0 == imp)
{
/* A class may not implement the selector (in which case we can't
* cache the method), but if it's going to forward the message to
* some other object it must at least say it responds to the
* selector.
*/
if ([observer respondsToSelector: selector] == NO) if ([observer respondsToSelector: selector] == NO)
NSLog(@"Observer '%@' does not respond to selector '%@'", observer, {
NSStringFromSelector(selector));
#endif
method = [observer methodForSelector: selector];
if (method == 0)
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"Observer can not handle specified selector"]; 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)
{ {
@ -1220,9 +1230,17 @@ static NSNotificationCenter *default_center = nil;
if (o->next != 0) if (o->next != 0)
{ {
NS_DURING NS_DURING
{
if (0 == o->method)
{
[o->observer performSelector: o->selector
withObject: notification];
}
else
{ {
(*o->method)(o->observer, o->selector, notification); (*o->method)(o->observer, o->selector, notification);
} }
}
NS_HANDLER NS_HANDLER
{ {
NSLog(@"Problem posting notification: %@", localException); NSLog(@"Problem posting notification: %@", localException);