Fix #32819: Crash when starting CUDA kernel compilation if UI translation is not "Default"

Issue was caused by some boost filesystem routines accessing current locale
and such an access failed in cases code page isn't specified for the current
locale.

Made it so UTF-8 locale name would be tried to be used first.
This commit is contained in:
Sergey Sharybin 2012-10-16 10:29:34 +00:00
parent aacdd76c06
commit 0ee9f123b2

@ -214,11 +214,33 @@ void BLF_lang_set(const char *str)
get_language_variable("LANGUAGE", default_language, sizeof(default_language));
if (short_locale[0]) {
if (G.debug & G_DEBUG)
printf("Setting LANG= and LANGUAGE to %s\n", short_locale);
char *short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale);
BLI_setenv("LANG", short_locale);
BLI_setenv("LANGUAGE", short_locale);
if (G.debug & G_DEBUG)
printf("Setting LANG and LANGUAGE to %s\n", short_locale_utf8);
locreturn = setlocale(LC_ALL, short_locale_utf8);
if (locreturn != NULL) {
BLI_setenv("LANG", short_locale_utf8);
BLI_setenv("LANGUAGE", short_locale_utf8);
}
else {
if (G.debug & G_DEBUG)
printf("Setting LANG and LANGUAGE to %s\n", short_locale);
locreturn = setlocale(LC_ALL, short_locale);
if (locreturn != NULL) {
BLI_setenv("LANG", short_locale);
BLI_setenv("LANGUAGE", short_locale);
}
}
if (G.debug & G_DEBUG && locreturn == NULL)
printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
MEM_freeN(short_locale_utf8);
}
else {
if (G.debug & G_DEBUG)
@ -226,43 +248,27 @@ void BLF_lang_set(const char *str)
BLI_setenv("LANG", default_lang);
BLI_setenv("LANGUAGE", default_language);
locreturn = setlocale(LC_ALL, "");
if (G.debug & G_DEBUG && locreturn == NULL)
printf("Could not reset locale\n");
}
locreturn = setlocale(LC_ALL, short_locale);
if (locreturn == NULL) {
char *short_locale_utf8 = NULL;
char language[65];
if (short_locale[0]) {
short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale);
locreturn = setlocale(LC_ALL, short_locale_utf8);
}
get_language(long_locale, default_lang, language, sizeof(language));
if (locreturn == NULL) {
char language[65];
if (G.debug & G_DEBUG)
printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language);
get_language(long_locale, default_lang, language, sizeof(language));
/* Fallback to default settings. */
BLI_setenv("LANG", default_lang);
BLI_setenv("LANGUAGE", language);
if (G.debug & G_DEBUG) {
if (short_locale[0])
printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
else
printf("Could not reset locale\n");
locreturn = setlocale(LC_ALL, "");
printf("Fallback to LANG=%s and LANGUAGE=%s\n", default_lang, language);
}
/* Fallback to default settings. */
BLI_setenv("LANG", default_lang);
BLI_setenv("LANGUAGE", language);
locreturn = setlocale(LC_ALL, "");
ok = 0;
}
if (short_locale_utf8)
MEM_freeN(short_locale_utf8);
ok = 0;
}
}
#endif