From 6d190c38f4c42f8f16200dc6836d995e2e461ba4 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 3 Feb 2006 07:51:36 +0000 Subject: [PATCH] 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 --- ChangeLog | 2 ++ Source/NSApplication.m | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc6abfdcf..199af3821 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/Source/NSApplication.m b/Source/NSApplication.m index b106b447a..d98044ac4 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -3337,16 +3337,46 @@ image.

See Also: -applicationIconImage

- (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; }