X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3cdd564fb9d9a982528131689e8f56e5ea946f13..5bf3b6fe48580853044132c381d3548535ca7ad1:/src/msw/utilsexc.cpp?ds=sidebyside diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 7c085553ed..aaf6176b1c 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -217,7 +217,7 @@ protected: protected: HANDLE m_hInput; - DECLARE_NO_COPY_CLASS(wxPipeInputStream) + wxDECLARE_NO_COPY_CLASS(wxPipeInputStream); }; class wxPipeOutputStream: public wxOutputStream @@ -233,7 +233,7 @@ protected: protected: HANDLE m_hOutput; - DECLARE_NO_COPY_CLASS(wxPipeOutputStream) + wxDECLARE_NO_COPY_CLASS(wxPipeOutputStream); }; // define this to let wxexec.cpp know that we know what we're doing @@ -899,6 +899,9 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler) { // may be NULL or not data->handler = handler; + + if (handler) + handler->SetPid(pi.dwProcessId); } DWORD tid; @@ -1032,16 +1035,28 @@ long wxExecuteImpl(CharType **argv, int flags, wxProcess *handler) { arg = *argv++; - // escape any quotes present in the string to avoid interfering with - // the command line parsing in the child process - arg.Replace("\"", "\\\"", true /* replace all */); + bool quote; + if ( arg.empty() ) + { + // we need to quote empty arguments, otherwise they'd just + // disappear + quote = true; + } + else // non-empty + { + // escape any quotes present in the string to avoid interfering + // with the command line parsing in the child process + arg.Replace("\"", "\\\"", true /* replace all */); - // and quote any arguments containing the spaces to prevent them from - // being broken down - if ( arg.find_first_of(" \t") == wxString::npos ) - command += arg; - else + // and quote any arguments containing the spaces to prevent them from + // being broken down + quote = arg.find_first_of(" \t") != wxString::npos; + } + + if ( quote ) command += '\"' + arg + '\"'; + else + command += arg; if ( !*argv ) break;