Avoid possible insertion of nil values in dictionary.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22416 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-02-03 07:51:36 +00:00
parent f39ba306a2
commit 6d190c38f4
2 changed files with 37 additions and 5 deletions

View file

@ -3,6 +3,8 @@
* Source/NSWorkspace.m: In GSLaunched() be more defensive and don't * Source/NSWorkspace.m: In GSLaunched() be more defensive and don't
assume that the values which should be present in the notification assume that the values which should be present in the notification
userinfo dictionry really are there. userinfo dictionry really are there.
* Source/NSApplication.m: Code more defensively setting up
notification info.
2006-02-02 Richard Frith-Macdonald <rfm@gnu.org> 2006-02-02 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -3337,16 +3337,46 @@ image.</p><p>See Also: -applicationIconImage</p>
- (NSDictionary*) _notificationUserInfo - (NSDictionary*) _notificationUserInfo
{ {
NSString *path;
NSString *port;
NSNumber *processIdentifier; NSNumber *processIdentifier;
NSDictionary *userInfo; NSDictionary *userInfo;
processIdentifier = [NSNumber numberWithInt: processIdentifier = [NSNumber numberWithInt:
[[NSProcessInfo processInfo] processIdentifier]]; [[NSProcessInfo processInfo] processIdentifier]];
userInfo = [NSDictionary dictionaryWithObjectsAndKeys: port = [(GSServicesManager*)_listener port];
[(GSServicesManager*)_listener port], @"NSApplicationName", path = [[NSBundle mainBundle] bundlePath];
[[NSBundle mainBundle] bundlePath], @"NSApplicationPath", if (port == nil)
processIdentifier, @"NSApplicationProcessIdentifier", {
nil]; if (path == nil)
{
userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
processIdentifier, @"NSApplicationProcessIdentifier",
nil];
}
else
{
userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
path, @"NSApplicationPath",
processIdentifier, @"NSApplicationProcessIdentifier",
nil];
}
}
else if (path == nil)
{
userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
port, @"NSApplicationName",
processIdentifier, @"NSApplicationProcessIdentifier",
nil];
}
else
{
userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
port, @"NSApplicationName",
path, @"NSApplicationPath",
processIdentifier, @"NSApplicationProcessIdentifier",
nil];
}
return userInfo; return userInfo;
} }