Mercurial > hg > piper-cpp
comparison vamp-client/ProcessQtTransport.h @ 114:95c94a86c902
Fix maddening failure to start server with space in its path
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 25 Oct 2016 21:06:38 +0100 |
parents | ac4a9518e1cc |
children | 5a716f08e4be |
comparison
equal
deleted
inserted
replaced
113:ac4a9518e1cc | 114:95c94a86c902 |
---|---|
28 ProcessQtTransport(std::string processName) : | 28 ProcessQtTransport(std::string processName) : |
29 m_completenessChecker(0) { | 29 m_completenessChecker(0) { |
30 m_process = new QProcess(); | 30 m_process = new QProcess(); |
31 m_process->setReadChannel(QProcess::StandardOutput); | 31 m_process->setReadChannel(QProcess::StandardOutput); |
32 m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel); | 32 m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel); |
33 m_process->start(processName.c_str()); | 33 QString name(QString::fromStdString(processName)); |
34 | |
35 // The second argument here is vital, otherwise we get a | |
36 // different start() overload which parses all command args | |
37 // out of its first argument only and therefore fails when | |
38 // name has a space in it. This is such a gotcha that Qt5.6 | |
39 // even introduced a QT_NO_PROCESS_COMBINED_ARGUMENT_START | |
40 // build flag to disable that overload. Unfortunately I only | |
41 // discovered that after wasting almost a day on it. | |
42 m_process->start(name, QStringList()); | |
43 | |
34 if (!m_process->waitForStarted()) { | 44 if (!m_process->waitForStarted()) { |
35 if (m_process->state() == QProcess::NotRunning) { | 45 if (m_process->state() == QProcess::NotRunning) { |
36 QProcess::ProcessError err = m_process->error(); | 46 QProcess::ProcessError err = m_process->error(); |
37 if (err == QProcess::FailedToStart) { | 47 if (err == QProcess::FailedToStart) { |
38 std::cerr << "Unable to start server process " | 48 std::cerr << "Unable to start server process " |