From a82fdbe74c05fd392f6cb771c12a5f315397975b Mon Sep 17 00:00:00 2001 From: Guy Rutenberg Date: Sat, 23 Sep 2017 18:55:35 +0300 Subject: [PATCH] Fix handling on non-ascii paths when stitching. This solves bug #678808, by working around a bug in the handling of non-ascii characters in wxExecute. --- src/hugin1/hugin/PanoPanel.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/hugin1/hugin/PanoPanel.cpp b/src/hugin1/hugin/PanoPanel.cpp index e014aa4..37588d1 100755 --- a/src/hugin1/hugin/PanoPanel.cpp +++ b/src/hugin1/hugin/PanoPanel.cpp @@ -1179,11 +1179,25 @@ void PanoPanel::DoStitch() return; }; - wxString switches(wxT(" --delete -o ")); - if(wxConfigBase::Get()->Read(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE) == 1) - switches=wxT(" --overwrite")+switches; - wxString command = hugin_stitch_project + switches + hugin_utils::wxQuoteFilename(dlg.GetPath()) + wxT(" ") + hugin_utils::wxQuoteFilename(currentPTOfn); - + // wxExecute(wxString, ...) is broken because it drops any non-ascii + // arguments. To work around it, at least until it is fixed by wxwidgets, + // we should split the arguments ourselves. In any case, it is a better + // practice as we can avoid doing unnecessary quoting (as wxWidgets has + // to unquote it anyway when it splits it to separate arguments). + std::vector argv; + argv.push_back(wxStrdup(hugin_stitch_project.wx_str())); + if (wxConfigBase::Get()->Read(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE) == 1) { + argv.push_back(wxStrdup(wxT("--overwrite"))); + } + argv.push_back(wxStrdup(wxT("--delete"))); + argv.push_back(wxStrdup(wxT("-o"))); + + // no need to quote the filenames, as each is in its own argument. + argv.push_back(wxStrdup(dlg.GetPath().wx_str())); + argv.push_back(wxStrdup(currentPTOfn.wx_str())); + + argv.push_back(NULL); + wxConfigBase::Get()->Flush(); #ifdef __WXGTK__ // work around a wxExecute bug/problem @@ -1193,10 +1207,18 @@ void PanoPanel::DoStitch() // Delete itself once processes terminated. my_process->Detach(); - wxExecute(command,wxEXEC_ASYNC, my_process); + wxExecute(&argv[0], wxEXEC_ASYNC, my_process); + #else - wxExecute(command); + wxExecute(&argv[0]); #endif + // free up all the strdup'ed strings + for (size_t i = 0; i < argv.size(); i++) { + if (argv[i]) { + free(argv[i]); + } + } + HuginBase::LensDB::SaveLensDataFromPano(*pano); } -- 2.11.0