[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51362] trunk/blender/source/blender/ blenfont/intern/blf_lang.c: Fix #32819: Crash when starting CUDA kernel compilation if UI translation is not " Default"

Sergey Sharybin sergey.vfx at gmail.com
Tue Oct 16 12:29:37 CEST 2012


Revision: 51362
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51362
Author:   nazgul
Date:     2012-10-16 10:29:34 +0000 (Tue, 16 Oct 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenfont/intern/blf_lang.c

Modified: trunk/blender/source/blender/blenfont/intern/blf_lang.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_lang.c	2012-10-16 09:11:07 UTC (rev 51361)
+++ trunk/blender/source/blender/blenfont/intern/blf_lang.c	2012-10-16 10:29:34 UTC (rev 51362)
@@ -214,11 +214,33 @@
 			get_language_variable("LANGUAGE", default_language, sizeof(default_language));
 
 		if (short_locale[0]) {
+			char *short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale);
+
 			if (G.debug & G_DEBUG)
-				printf("Setting LANG= and LANGUAGE to %s\n", short_locale);
+				printf("Setting LANG and LANGUAGE to %s\n", short_locale_utf8);
 
-			BLI_setenv("LANG", short_locale);
-			BLI_setenv("LANGUAGE", short_locale);
+			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 @@
 
 			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




More information about the Bf-blender-cvs mailing list