commit d996ec89928efb3042325fa158e1d5547b9eb64d
Author: Enrico Forestieri <for...@lyx.org>
Date:   Tue Mar 28 01:32:59 2017 +0200

    On windows, use the unicode version of ShellExecute
---
 src/support/os_cygwin.cpp |   17 ++++++-----------
 src/support/os_win32.cpp  |   15 +++++----------
 2 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/support/os_cygwin.cpp b/src/support/os_cygwin.cpp
index c2bdb38..702d67f 100644
--- a/src/support/os_cygwin.cpp
+++ b/src/support/os_cygwin.cpp
@@ -456,19 +456,14 @@ bool autoOpenFile(string const & filename, auto_open_mode 
const mode,
                cygwin_internal(CW_SYNC_WINENV);
        }
 
-       string win_path;
-       try {
-               win_path = to_local8bit(from_utf8(convert_path(filename, 
PathStyle(windows))));
-       } catch (...) {
-               LYXERR0("Cannot encode file name `" << filename << "' to local 
8 bit encoding");
-               return false;
-       }
-
+       QString const win_path =
+               toqstr(convert_path(filename, PathStyle(windows)));
 
        // reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
-       char const * action = (mode == VIEW) ? "open" : "edit";
-       bool success = reinterpret_cast<long>(ShellExecute(NULL, action,
-                                       win_path.c_str(), NULL, NULL, 1)) > 32;
+       wchar_t const * action = (mode == VIEW) ? L"open" : L"edit";
+       bool success = reinterpret_cast<long>(ShellExecuteW(NULL, action,
+                       reinterpret_cast<wchar_t const *>(win_path.utf16()),
+                       NULL, NULL, 1)) > 32;
 
        if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
                setEnv("TEXINPUTS", oldtexinputs);
diff --git a/src/support/os_win32.cpp b/src/support/os_win32.cpp
index e947b7f..a5b5bbe 100644
--- a/src/support/os_win32.cpp
+++ b/src/support/os_win32.cpp
@@ -567,18 +567,13 @@ bool autoOpenFile(string const & filename, auto_open_mode 
const mode,
                setEnv("TEXFONTS", newtexfonts);
        }
 
-       string fname8;
-       try {
-               fname8 = to_local8bit(from_utf8(filename));
-       } catch (...) {
-               LYXERR0("Cannot encode file name `" << filename << "' to local 
8 bit encoding");
-               return false;
-       }
+       QString const wname = toqstr(filename);
 
        // reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
-       char const * action = (mode == VIEW) ? "open" : "edit";
-       bool success = reinterpret_cast<intptr_t>(ShellExecute(NULL, action,
-               fname8.c_str(), NULL, NULL, 1)) > 32;
+       wchar_t const * action = (mode == VIEW) ? L"open" : L"edit";
+       bool success = reinterpret_cast<intptr_t>(ShellExecuteW(NULL, action,
+                       reinterpret_cast<wchar_t const *>(wname.utf16()),
+                       NULL, NULL, 1)) > 32;
 
        if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
                setEnv("TEXINPUTS", oldtexinputs);

Reply via email to