[Bf-blender-cvs] [40b6df7] soc-2014-viewport_fx: Moved and deleted some code from GHOST Cocoa moved locale query to the intern/locale module deleted some odd code that did not appear to be actually used relating to command line arguments

Jason Wilkins noreply at git.blender.org
Thu Jul 10 04:32:03 CEST 2014


Commit: 40b6df78512a1a42c468a63ad38810b3f6ae4a83
Author: Jason Wilkins
Date:   Wed Jul 9 17:56:49 2014 -0500
https://developer.blender.org/rB40b6df78512a1a42c468a63ad38810b3f6ae4a83

Moved and deleted some code from GHOST Cocoa
moved locale query to the intern/locale module
deleted some odd code that did not appear to be actually used relating to command line arguments

===================================================================

M	intern/ghost/intern/GHOST_SystemCocoa.mm
M	intern/locale/CMakeLists.txt
M	intern/locale/boost_locale_wrapper.cpp
M	intern/locale/boost_locale_wrapper.h
A	intern/locale/osx_user_locale.mm
M	source/creator/creator.c

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 2613f8a..1d4c6d5 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -254,27 +254,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
 }
 
 
-#pragma mark defines for 10.6 api not documented in 10.5
-
-#pragma mark Utility functions
-
-#define FIRSTFILEBUFLG 512
-static bool g_hasFirstFile = false;
-static char g_firstFileBuf[512];
-
-//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true
-extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
-{
-	if (g_hasFirstFile) {
-		strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
-		buf[FIRSTFILEBUFLG - 1] = '\0';
-		return 1;
-	}
-	else {
-		return 0; 
-	}
-}
-
 #pragma mark Cocoa objects
 
 /**
@@ -338,8 +317,6 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
 
 #pragma mark initialization/finalization
 
-char GHOST_user_locale[128]; // Global current user locale
-
 GHOST_SystemCocoa::GHOST_SystemCocoa()
 {
 	int mib[2];
@@ -377,15 +354,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
 	rstring = NULL;
 	
 	m_ignoreWindowSizedMessages = false;
-	
-	//Get current locale
-	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-	CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
-	NSLocale * myNSLocale = (NSLocale *) myCFLocale;
-	[myNSLocale autorelease];
-	NSString *nsIdentifier = [myNSLocale localeIdentifier];
-	strncpy(GHOST_user_locale, [nsIdentifier UTF8String], sizeof(GHOST_user_locale) - 1);
-	[pool drain];
 }
 
 GHOST_SystemCocoa::~GHOST_SystemCocoa()
diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt
index 217fe9a..5a59f41 100644
--- a/intern/locale/CMakeLists.txt
+++ b/intern/locale/CMakeLists.txt
@@ -36,6 +36,12 @@ set(SRC
 	boost_locale_wrapper.h
 )
 
+if(APPLE)
+	list(APPEND SRC
+		osx_user_locale.mm
+	)
+endif()
+
 if(WITH_HEADLESS)
 	add_definitions(-DWITH_HEADLESS)
 endif()
diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp
index 25843d6..5eb2f7f 100644
--- a/intern/locale/boost_locale_wrapper.cpp
+++ b/intern/locale/boost_locale_wrapper.cpp
@@ -65,8 +65,7 @@ void bl_locale_set(const char *locale)
 		}
 		else {
 #if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
-			extern char GHOST_user_locale[128]; // pulled from Ghost_SystemCocoa
-			std::string locale_osx = GHOST_user_locale + std::string(".UTF-8");
+			std::string locale_osx = osx_user_locale() + std::string(".UTF-8");
 			_locale = gen(locale_osx.c_str());
 #else
 			_locale = gen("");
diff --git a/intern/locale/boost_locale_wrapper.h b/intern/locale/boost_locale_wrapper.h
index ff3645a..f7bc7b4 100644
--- a/intern/locale/boost_locale_wrapper.h
+++ b/intern/locale/boost_locale_wrapper.h
@@ -42,7 +42,11 @@ void bl_locale_init(const char *messages_path, const char *default_domain);
 void bl_locale_set(const char *locale);
 const char *bl_locale_get(void);
 const char *bl_locale_pgettext(const char *msgctxt, const char *msgid);
-	
+
+#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
+const char* osx_user_locale(void);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/intern/locale/osx_user_locale.mm b/intern/locale/osx_user_locale.mm
new file mode 100644
index 0000000..1ed33bb
--- /dev/null
+++ b/intern/locale/osx_user_locale.mm
@@ -0,0 +1,22 @@
+#include "boost_locale_wrapper.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include <cstdlib>
+
+static char* user_locale = NULL;
+
+// get current locale
+const char* osx_user_locale()
+{
+	::free(user_locale);
+	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+	CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
+	NSLocale * myNSLocale = (NSLocale *) myCFLocale;
+	[myNSLocale autorelease];
+	NSString *nsIdentifier = [myNSLocale localeIdentifier];
+	user_locale = ::strdup([nsIdentifier UTF8String]);
+	[pool drain];
+
+	return user_locale;
+}
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 70e6aba..25455c9 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -1574,21 +1574,6 @@ int main(
 #endif
 
 	setCallbacks();
-#if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE)
-	/* patch to ignore argument finder gives us (pid?) */
-	if (argc == 2 && strncmp(argv[1], "-psn_", 5) == 0) {
-		extern int GHOST_HACK_getFirstFile(char buf[]);
-		static char firstfilebuf[512];
-
-		argc = 1;
-
-		if (GHOST_HACK_getFirstFile(firstfilebuf)) {
-			argc = 2;
-			argv[1] = firstfilebuf;
-		}
-	}
-
-#endif
 
 #ifdef __FreeBSD__
 	fpsetmask(0);




More information about the Bf-blender-cvs mailing list