From 923925780650de4736d580f984a6b6001b786a15 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 May 2016 14:30:41 +0200 Subject: Fix T48393: Blender player doesn't start on files saved with with cyrillic letters in path --- source/gameengine/GamePlayer/ghost/CMakeLists.txt | 4 ++ source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 57 +++++++++++++++++++++-- 2 files changed, 56 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 283f222115c..6c09af33f9e 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -77,6 +77,10 @@ set(SRC add_definitions(${GL_DEFINITIONS}) +if(WIN32) + blender_include_dirs(../../../../intern/utfconv) +endif() + if(WITH_CODEC_FFMPEG) add_definitions(-DWITH_FFMPEG) endif() diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index a69a8eae55d..4d2c5bb0c14 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -116,10 +116,14 @@ extern char datatoc_bmonofont_ttf[]; #include "RNA_define.h" #ifdef WIN32 -#include -#if !defined(DEBUG) -#include -#endif // !defined(DEBUG) +# include +# if !defined(DEBUG) +# include +# endif // !defined(DEBUG) +# if defined(_MSC_VER) && defined(_M_X64) +# include /* needed for _set_FMA3_enable */ +# endif +# include "utfconv.h" #endif // WIN32 #ifdef WITH_SDL_DYNLOAD @@ -399,7 +403,14 @@ static int GPG_PyNextFrame(void *state0) } } -int main(int argc, char** argv) +int main( + int argc, +#ifdef WIN32 + const char **UNUSED(argv_c) +#else + const char **argv +#endif + ) { int i; int argc_py_clamped= argc; /* use this so python args can be added after ' - ' */ @@ -434,6 +445,34 @@ int main(int argc, char** argv) bool samplesParFound = false; GHOST_TUns16 aasamples = 0; +#ifdef WIN32 + char **argv; + int argv_num; + + /* We delay loading of openmp so we can set the policy here. */ +# if defined(_MSC_VER) + _putenv_s("OMP_WAIT_POLICY", "PASSIVE"); +# endif + + /* FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). Just disable it. */ +# if defined(_MSC_VER) && defined(_M_X64) + _set_FMA3_enable(0); +# endif + + /* Win32 Unicode Args */ + /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized + * (it depends on the args passed in, which is what we're getting here!) + */ + { + wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc); + argv = (char**)malloc(argc * sizeof(char *)); + for (argv_num = 0; argv_num < argc; argv_num++) { + argv[argv_num] = alloc_utf_8_from_16(argv_16[argv_num], 0); + } + LocalFree(argv_16); + } +#endif /* WIN32 */ + #ifdef __linux__ #ifdef __alpha__ signal (SIGFPE, SIG_IGN); @@ -1165,5 +1204,13 @@ int main(int argc, char** argv) BKE_tempdir_session_purge(); +#ifdef WIN32 + while (argv_num) { + free(argv[--argv_num]); + } + free(argv); + argv = NULL; +#endif + return error ? -1 : 0; } -- cgit v1.2.3