Apparently, passing nil to fileURLWithPath: also causes an exception. Fixes a bug reported by “~HP” on the forums: http://forums.cocoaforge.com/viewtopic.php?p=114476#p114476
1.1 --- a/Extras/growlnotify/main.m Thu Feb 26 20:56:38 2009 -0800
1.2 +++ b/Extras/growlnotify/main.m Sat Feb 28 19:10:16 2009 -0800
1.3 @@ -296,16 +296,22 @@
1.4 } else if (appIcon) {
1.5 // get icon data for application name
1.6 CFStringRef app = CFStringCreateWithCString(kCFAllocatorDefault, appIcon, kCFStringEncodingUTF8);
1.7 - NSURL *appURL = [NSURL fileURLWithPath:[[NSWorkspace sharedWorkspace] fullPathForApplication:(NSString *)app]];
1.8 - if (appURL) {
1.9 - icon = (CFDataRef)copyIconDataForURL(appURL);
1.10 + NSString *appPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:(NSString *)app];
1.11 + if (appPath) {
1.12 + NSURL *appURL = [NSURL fileURLWithPath:appPath];
1.13 + if (appURL) {
1.14 + icon = (CFDataRef)copyIconDataForURL(appURL);
1.15 + }
1.16 }
1.17 CFRelease(app);
1.18 }
1.19 if (!icon) {
1.20 - NSURL *appURL = [NSURL fileURLWithPath:[[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.Terminal"]];
1.21 - if (appURL) {
1.22 - icon = (CFDataRef)copyIconDataForURL((NSURL *)appURL);
1.23 + NSString *appPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.Terminal"];
1.24 + if (appPath) {
1.25 + NSURL *appURL = [NSURL fileURLWithPath:appPath];
1.26 + if (appURL) {
1.27 + icon = (CFDataRef)copyIconDataForURL((NSURL *)appURL);
1.28 + }
1.29 }
1.30 }
1.31