mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Bugfix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14253 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f57005916c
commit
ca85b74c94
2 changed files with 62 additions and 36 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2002-08-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSNotificationCenter.m: ([-postNotification:]) Correct to
|
||||||
|
post the actual notification we are given rather than a notification
|
||||||
|
built from that one. Bug report by Alexander Malmberg.
|
||||||
|
|
||||||
2002-08-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2002-08-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSProcessInfo.m: ([-globallyUniqueString]) Ensure that the
|
* Source/NSProcessInfo.m: ([-globallyUniqueString]) Ensure that the
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/** Implementation of NSNotificationCenter for GNUstep
|
/** Implementation of NSNotificationCenter for GNUstep
|
||||||
|
notification = (id)NSAllocateObject(concrete, 0, NSDefaultMallocZone());
|
||||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
@ -934,53 +935,26 @@ static NSNotificationCenter *default_center = nil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts notification to all the observers that match its NAME and OBJECT.<br />
|
* Private method to perform the actual posting of a notification.
|
||||||
* The GNUstep implementation calls -postNotificationName:object:userInfo: to
|
* Release the notification before returning, or before we raise
|
||||||
* perform the actual posting.
|
* any exception ... to avoid leaks.
|
||||||
*/
|
*/
|
||||||
- (void) postNotification: (NSNotification*)notification
|
- (void) _postAndRelease: (NSNotification*)notification
|
||||||
{
|
|
||||||
[self postNotificationName: [notification name]
|
|
||||||
object: [notification object]
|
|
||||||
userInfo: [notification userInfo]];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and posts a notification using the
|
|
||||||
* -postNotificationName:object:userInfo: passing a nil user info argument.
|
|
||||||
*/
|
|
||||||
- (void) postNotificationName: (NSString*)name
|
|
||||||
object: (id)object
|
|
||||||
{
|
|
||||||
[self postNotificationName: name object: object userInfo: nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The preferred method for posting a notification.
|
|
||||||
* <br />
|
|
||||||
* For performance reasons, we don't wrap an exception handler round every
|
|
||||||
* message sent to an observer. This means that, if one observer raises
|
|
||||||
* an exception, later observers in the lists will not get the notification.
|
|
||||||
*/
|
|
||||||
- (void) postNotificationName: (NSString*)name
|
|
||||||
object: (id)object
|
|
||||||
userInfo: (NSDictionary*)info
|
|
||||||
{
|
{
|
||||||
Observation *o;
|
Observation *o;
|
||||||
unsigned count;
|
unsigned count;
|
||||||
volatile GSIArray a;
|
volatile GSIArray a;
|
||||||
unsigned arrayBase;
|
unsigned arrayBase;
|
||||||
GSNotification *notification;
|
NSString *name = [notification name];
|
||||||
|
id object;
|
||||||
|
|
||||||
if (name == nil)
|
if (name == nil)
|
||||||
{
|
{
|
||||||
|
RELEASE(notification);
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"Tried to post a notification with no name."];
|
format: @"Tried to post a notification with no name."];
|
||||||
}
|
}
|
||||||
notification = (id)NSAllocateObject(concrete, 0, NSDefaultMallocZone());
|
object = TEST_RETAIN([notification object]);
|
||||||
name = notification->_name = [name copyWithZone: GSObjCZone(self)];
|
|
||||||
object = notification->_object = TEST_RETAIN(object);
|
|
||||||
notification->_info = TEST_RETAIN(info);
|
|
||||||
if (object != nil)
|
if (object != nil)
|
||||||
{
|
{
|
||||||
object = CHEATGC(object);
|
object = CHEATGC(object);
|
||||||
|
@ -1207,7 +1181,7 @@ static NSNotificationCenter *default_center = nil;
|
||||||
GSIArrayRemoveItemsFromIndex(ARRAY, arrayBase);
|
GSIArrayRemoveItemsFromIndex(ARRAY, arrayBase);
|
||||||
unlockNCTable(TABLE);
|
unlockNCTable(TABLE);
|
||||||
|
|
||||||
DESTROY(notification); // Get rid of notification we created.
|
RELEASE(notification);
|
||||||
[localException raise];
|
[localException raise];
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
@ -1217,6 +1191,52 @@ static NSNotificationCenter *default_center = nil;
|
||||||
RELEASE(notification);
|
RELEASE(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts notification to all the observers that match its NAME and OBJECT.<br />
|
||||||
|
* The GNUstep implementation calls -postNotificationName:object:userInfo: to
|
||||||
|
* perform the actual posting.
|
||||||
|
*/
|
||||||
|
- (void) postNotification: (NSNotification*)notification
|
||||||
|
{
|
||||||
|
if (notification == nil)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"Tried to post a nil notification."];
|
||||||
|
}
|
||||||
|
[self _postAndRelease: RETAIN(notification)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and posts a notification using the
|
||||||
|
* -postNotificationName:object:userInfo: passing a nil user info argument.
|
||||||
|
*/
|
||||||
|
- (void) postNotificationName: (NSString*)name
|
||||||
|
object: (id)object
|
||||||
|
{
|
||||||
|
[self postNotificationName: name object: object userInfo: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The preferred method for posting a notification.
|
||||||
|
* <br />
|
||||||
|
* For performance reasons, we don't wrap an exception handler round every
|
||||||
|
* message sent to an observer. This means that, if one observer raises
|
||||||
|
* an exception, later observers in the lists will not get the notification.
|
||||||
|
*/
|
||||||
|
- (void) postNotificationName: (NSString*)name
|
||||||
|
object: (id)object
|
||||||
|
userInfo: (NSDictionary*)info
|
||||||
|
{
|
||||||
|
GSNotification *notification;
|
||||||
|
|
||||||
|
notification = (id)NSAllocateObject(concrete, 0, NSDefaultMallocZone());
|
||||||
|
name = notification->_name = [name copyWithZone: GSObjCZone(self)];
|
||||||
|
object = notification->_object = TEST_RETAIN(object);
|
||||||
|
notification->_info = TEST_RETAIN(info);
|
||||||
|
[self _postAndRelease: notification];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSNotificationCenter (GNUstep)
|
@implementation NSNotificationCenter (GNUstep)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue