From b828d7c27491b373faf58b5c239338f6529e335b Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 25 Aug 2021 00:15:00 +0200 Subject: [PATCH] Fix launching Syncthing with program/args containing non-ASCII characters * Pass program/args for Syncthing launcher using UTF-16 under Windows * See https://github.com/Martchus/syncthingtray/issues/107 --- connector/syncthingprocess.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/connector/syncthingprocess.cpp b/connector/syncthingprocess.cpp index fe266f4..7c7454c 100644 --- a/connector/syncthingprocess.cpp +++ b/connector/syncthingprocess.cpp @@ -42,8 +42,10 @@ namespace Data { #ifdef LIB_SYNCTHING_CONNECTOR_BOOST_PROCESS #ifdef PLATFORM_WINDOWS #define LIB_SYNCTHING_CONNECTOR_PLATFORM_ARGS boost::process::windows::create_no_window, +#define LIB_SYNCTHING_CONNECTOR_STRING_CONVERSION toStdWString #else #define LIB_SYNCTHING_CONNECTOR_PLATFORM_ARGS +#define LIB_SYNCTHING_CONNECTOR_STRING_CONVERSION toLocal8Bit().toStdString #endif /// \brief Holds data related to the process execution via Boost.Process. @@ -384,11 +386,11 @@ void SyncthingProcess::start(const QString &program, const QStringList &argument emit stateChanged(m_process->state = QProcess::Starting); // convert args - auto prog = program.toStdString(); - auto args = std::vector(); + auto prog = program.LIB_SYNCTHING_CONNECTOR_STRING_CONVERSION(); + auto args = std::vector(); args.reserve(static_cast(arguments.size())); for (const auto &arg : arguments) { - args.emplace_back(arg.toStdString()); + args.emplace_back(arg.LIB_SYNCTHING_CONNECTOR_STRING_CONVERSION()); } m_process->program = program; m_process->arguments = arguments;