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:
Richard Frith-MacDonald 2006-02-03 07:51:36 +00:00
parent b93e73b1a9
commit 5ce34d9470
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
assume that the values which should be present in the notification
userinfo dictionry really are there.
* Source/NSApplication.m: Code more defensively setting up
notification info.
2006-02-02 Richard Frith-Macdonald <rfm@gnu.org>

View file

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