Fix T41629: Won't open blend files with non-Latin charasters in the name

This commit is contained in:
Sergey Sharybin
2014-08-29 23:05:14 +06:00
parent cba2e0afa7
commit 526ae635d1
3 changed files with 34 additions and 19 deletions

View File

@@ -848,7 +848,7 @@ if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
lenv.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS']) lenv.Append(LINKFLAGS = env['PLATFORM_LINKFLAGS'])
targetpath = B.root_build_dir + '/blender' targetpath = B.root_build_dir + '/blender'
launcher_obj = [env.Object(B.root_build_dir + 'source/creator/creator/creator_launch_win', ['#source/creator/creator_launch_win.c'])] launcher_obj = [env.Object(B.root_build_dir + 'source/creator/creator/creator_launch_win', ['#source/creator/creator_launch_win.c'])]
env.BlenderProg(B.root_build_dir, 'blender', [launcher_obj] + B.resources, [], [], 'blender') env.BlenderProg(B.root_build_dir, 'blender', [launcher_obj] + B.resources, ['bf_utfconv'] + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
env.BlenderProg(B.root_build_dir, blender_progname, creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender') env.BlenderProg(B.root_build_dir, blender_progname, creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
if env['WITH_BF_PLAYER']: if env['WITH_BF_PLAYER']:

View File

@@ -942,7 +942,7 @@ if(WIN32 AND NOT WITH_PYTHON_MODULE)
../icons/winblender.rc ../icons/winblender.rc
) )
add_executable(blender-launcher ${LAUNCHER_SRC}) add_executable(blender-launcher ${LAUNCHER_SRC})
target_link_libraries(blender-launcher ${PLATFORM_LINKLIBS}) target_link_libraries(blender-launcher bf_intern_utfconv ${PLATFORM_LINKLIBS})
set_target_properties(blender PROPERTIES OUTPUT_NAME blender-app) set_target_properties(blender PROPERTIES OUTPUT_NAME blender-app)
set_target_properties(blender-launcher PROPERTIES OUTPUT_NAME blender) set_target_properties(blender-launcher PROPERTIES OUTPUT_NAME blender)

View File

@@ -24,40 +24,55 @@
*/ */
/* Binary name to launch. */ /* Binary name to launch. */
#define BLENDER_BINARY "blender-app.exe" #define BLENDER_BINARY L"blender-app.exe"
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <windows.h>
int main(int argc, char **argv) #include <windows.h>
#include <Shellapi.h>
#include "utfconv.h"
#include "BLI_utildefines.h"
#include "BLI_winstuff.h"
static void local_hacks_do(void)
{
_putenv_s("OMP_WAIT_POLICY", "PASSIVE");
}
int main(int argc, const char **UNUSED(argv_c))
{ {
PROCESS_INFORMATION processInformation = {0}; PROCESS_INFORMATION processInformation = {0};
STARTUPINFOA startupInfo = {0}; STARTUPINFOW startupInfo = {0};
BOOL result; BOOL result;
char command[65536]; wchar_t command[65536];
int i, len = sizeof(command); int i, len = sizeof(command) / sizeof(wchar_t);
wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc);
int argci = 0;
_putenv_s("OMP_WAIT_POLICY", "PASSIVE"); local_hacks_do();
startupInfo.cb = sizeof(startupInfo); wcsncpy(command, BLENDER_BINARY, len - 1);
len -= wcslen(BLENDER_BINARY);
strncpy(command, BLENDER_BINARY, len - 1);
len -= strlen(BLENDER_BINARY);
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {
strncat(command, " \"", len - 2); wcsncat(command, L" \"", len - 2);
strncat(command, argv[i], len - 3); wcsncat(command, argv_16[i], len - 3);
len -= strlen(argv[i]) + 1; len -= wcslen(argv_16[i]) + 1;
strncat(command, "\"", len - 1); wcsncat(command, L"\"", len - 1);
} }
result = CreateProcessA(NULL, command, NULL, NULL, TRUE, LocalFree(argv_16);
startupInfo.cb = sizeof(startupInfo);
result = CreateProcessW(NULL, command, NULL, NULL, TRUE,
0, NULL, NULL, 0, NULL, NULL,
&startupInfo, &processInformation); &startupInfo, &processInformation);
if (!result) { if (!result) {
fprintf(stderr, "Error launching " BLENDER_BINARY "\n"); fprintf(stderr, "%S\n", L"Error launching " BLENDER_BINARY);
return EXIT_FAILURE; return EXIT_FAILURE;
} }