[r23150]Handle exception in set_mac_locale()

When [locale objectForKey: NSLocaleCountryCode] returns nil

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/2.4@23151 57a11ea4-9604-0410-9ed3-97b8803252fd
2.4
John Ralls 13 years ago
parent 96f535fdf8
commit 7bb0ec7dce

@ -279,10 +279,22 @@ set_mac_locale()
NSArray *languages = [defs objectForKey: @"AppleLanguages"];
const gchar *langs = NULL;
NSLocale *locale = [NSLocale currentLocale];
NSString *locale_str = [[[locale objectForKey: NSLocaleLanguageCode]
stringByAppendingString: @"_"]
stringByAppendingString:
[locale objectForKey: NSLocaleCountryCode]];
NSString *locale_str;
@try
{
locale_str = [[[locale objectForKey: NSLocaleLanguageCode]
stringByAppendingString: @"_"]
stringByAppendingString:
[locale objectForKey: NSLocaleCountryCode]];
}
@catch (NSException *err)
{
PWARN("Locale detection raised error %s: %s. "
"Check that your locale settings in "
"System Preferences>Languages & Text are set correctly.",
[[err name] UTF8String], [[err reason] UTF8String]);
locale_str = @"_";
}
/* If we didn't get a valid current locale, the string will be just "_" */
if ([locale_str isEqualToString: @"_"])
locale_str = @"en_US";

Loading…
Cancel
Save