mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 634334: Check that subdir argument really is one of the two cases
we can handle. Wrap fileURLWithPath in @try/@catch so that we don't crash when it throws. Free bonus fix: If "en" is the language and doesn't have a translation, force the C locale. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19785 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f0a7805f27
commit
cc2c20a1de
@ -285,16 +285,19 @@ gnc_gnome_help (const char *dir, const char *detail)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *subdir = [NSString stringWithUTF8String: dir];
|
||||
NSString *help_dir = [NSString stringWithUTF8String: HF_HELP];
|
||||
NSString *tag;
|
||||
NSURL *url = NULL;
|
||||
|
||||
if (detail)
|
||||
tag = [NSString stringWithUTF8String: detail];
|
||||
else if ([subdir compare: help_dir] == NSOrderedSame)
|
||||
else if ([subdir compare: @HF_HELP] == NSOrderedSame)
|
||||
tag = @"help";
|
||||
else
|
||||
else if ([subdir compare: @HF_GUIDE] == NSOrderedSame)
|
||||
tag = @"index";
|
||||
else {
|
||||
PWARN("gnc_gnome_help called with unknown subdirectory %s", dir);
|
||||
return;
|
||||
}
|
||||
|
||||
if (![[NSBundle mainBundle] bundleIdentifier]) {
|
||||
/* If bundleIdentifier is NULL, then we're running from the
|
||||
@ -345,31 +348,54 @@ gnc_gnome_help (const char *dir, const char *detail)
|
||||
fileExistsAtPath: completed_path
|
||||
isDirectory: &dir])
|
||||
if (dir) {
|
||||
url = [NSURL fileURLWithPath:
|
||||
[[[completed_path
|
||||
stringByAppendingPathComponent: subdir]
|
||||
stringByAppendingPathComponent: tag]
|
||||
stringByAppendingPathExtension: @"html"]];
|
||||
@try {
|
||||
url = [NSURL fileURLWithPath:
|
||||
[[[completed_path
|
||||
stringByAppendingPathComponent: subdir]
|
||||
stringByAppendingPathComponent: tag]
|
||||
stringByAppendingPathExtension: @"html"]];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
PWARN("fileURLWithPath threw %s: %s",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ([this_lang compare:@"en"] == NSOrderedSame)
|
||||
break; /* Special case, forces use of "C" locale */
|
||||
}
|
||||
}
|
||||
if (!url) {
|
||||
@try {
|
||||
url = [NSURL
|
||||
fileURLWithPath: [[[[docs_dir
|
||||
stringByAppendingPathComponent: @"C"]
|
||||
stringByAppendingPathComponent: subdir]
|
||||
stringByAppendingPathComponent: tag]
|
||||
stringByAppendingPathExtension: @"html"]];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
PWARN("fileURLWithPath threw %s: %s",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!url)
|
||||
url = [NSURL
|
||||
fileURLWithPath: [[[[docs_dir
|
||||
stringByAppendingPathComponent: @"C"]
|
||||
stringByAppendingPathComponent: subdir]
|
||||
stringByAppendingPathComponent: tag]
|
||||
stringByAppendingPathExtension: @"html"]];
|
||||
|
||||
}
|
||||
/* It's a lot easier in a bundle! OSX finds the best translation for us. */
|
||||
else
|
||||
url = [NSURL fileURLWithPath: [[NSBundle mainBundle]
|
||||
pathForResource: tag
|
||||
ofType: @"html"
|
||||
inDirectory: subdir ]];
|
||||
|
||||
else {
|
||||
@try {
|
||||
url = [NSURL fileURLWithPath: [[NSBundle mainBundle]
|
||||
pathForResource: tag
|
||||
ofType: @"html"
|
||||
inDirectory: subdir ]];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
PWARN("fileURLWithPath threw %s: %s",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Now just open the URL in the default app for opening URLs */
|
||||
if (url)
|
||||
[[NSWorkspace sharedWorkspace] openURL: url];
|
||||
|
Loading…
Reference in New Issue
Block a user