From 7bb0ec7dcefa7b436e86400d59d0e5159a45009b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 26 Aug 2013 17:11:40 +0000 Subject: [PATCH] [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 --- src/bin/gnucash-bin.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/bin/gnucash-bin.c b/src/bin/gnucash-bin.c index 1d078e2072..59c54a1fb5 100644 --- a/src/bin/gnucash-bin.c +++ b/src/bin/gnucash-bin.c @@ -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";