diff options
Diffstat (limited to 'indra/newview/llfloateruipreview.cpp')
-rw-r--r-- | indra/newview/llfloateruipreview.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp index 1e92ac0b8e..c6e12476bd 100644 --- a/indra/newview/llfloateruipreview.cpp +++ b/indra/newview/llfloateruipreview.cpp @@ -1051,6 +1051,7 @@ void LLFloaterUIPreview::onClickEditFloater() if(!LLFile::stat(exe_path.c_str(), &s)) // If the executable exists { // build paths and arguments + std::string quote = std::string("\""); std::string args; std::string custom_args = mEditorArgsTextBox->getText(); int position_of_file = custom_args.find(std::string("%FILE%"), 0); // prepare to replace %FILE% with actual file path @@ -1058,7 +1059,7 @@ void LLFloaterUIPreview::onClickEditFloater() std::string second_part_of_args = ""; if(-1 == position_of_file) // default: Executable.exe File.xml { - args = std::string("\"") + path + std::string("\""); // execute the command Program.exe "File.xml" + args = quote + path + quote; // execute the command Program.exe "File.xml" } else // use advanced command-line arguments, e.g. "Program.exe -safe File.xml" -windowed for "-safe %FILE% -windowed" { @@ -1085,12 +1086,14 @@ void LLFloaterUIPreview::onClickEditFloater() memset(&pinfo, 0, sizeof(pinfo)); std::string exe_name = exe_path.substr(last_slash_position+1); - args = exe_name + std::string(" ") + args; // and prepend the executable name, so we get 'Program.exe "Arg1"' + args = quote + exe_name + quote + std::string(" ") + args; // and prepend the executable name, so we get 'Program.exe "Arg1"' char *args2 = new char[args.size() + 1]; // Windows requires that the second parameter to CreateProcessA be a writable (non-const) string... strcpy(args2, args.c_str()); - if(!CreateProcessA(exe_path.c_str(), args2, NULL, NULL, FALSE, 0, NULL, exe_dir.c_str(), &sinfo, &pinfo)) + // we don't want the current directory to be the executable directory, since the file path is now relative. By using + // NULL for the current directory instead of exe_dir.c_str(), the path to the target file will work. + if(!CreateProcessA(exe_path.c_str(), args2, NULL, NULL, FALSE, 0, NULL, NULL, &sinfo, &pinfo)) { // DWORD dwErr = GetLastError(); std::string warning = "Creating editor process failed!"; |