Mercurial > hg > piper-cpp
comparison vamp-client/ProcessQtTransport.h @ 119:5876f3e9c677
Fix server invocations from client code
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 27 Oct 2016 12:04:44 +0100 |
parents | ff3fd8d1b2dc |
children | 56e537a7bb99 |
comparison
equal
deleted
inserted
replaced
118:ff3fd8d1b2dc | 119:5876f3e9c677 |
---|---|
56 * serializes explicitly using a mutex. | 56 * serializes explicitly using a mutex. |
57 */ | 57 */ |
58 class ProcessQtTransport : public SynchronousTransport | 58 class ProcessQtTransport : public SynchronousTransport |
59 { | 59 { |
60 public: | 60 public: |
61 ProcessQtTransport(std::string processName) : | 61 ProcessQtTransport(std::string processName, std::string formatArg) : |
62 m_completenessChecker(0) { | 62 m_completenessChecker(0) { |
63 | |
63 m_process = new QProcess(); | 64 m_process = new QProcess(); |
64 m_process->setReadChannel(QProcess::StandardOutput); | 65 m_process->setReadChannel(QProcess::StandardOutput); |
65 m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel); | 66 m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel); |
66 QString name(QString::fromStdString(processName)); | |
67 | 67 |
68 // The second argument here is vital, otherwise we get a | 68 m_process->start(QString::fromStdString(processName), |
69 // different start() overload which parses all command args | 69 { QString::fromStdString(formatArg) }); |
70 // out of its first argument only and therefore fails when | |
71 // name has a space in it. This is such a gotcha that Qt5.6 | |
72 // even introduced a QT_NO_PROCESS_COMBINED_ARGUMENT_START | |
73 // build flag to disable that overload. Unfortunately I only | |
74 // discovered that after wasting almost a day on it. | |
75 m_process->start(name, QStringList()); | |
76 | 70 |
77 if (!m_process->waitForStarted()) { | 71 if (!m_process->waitForStarted()) { |
78 if (m_process->state() == QProcess::NotRunning) { | 72 if (m_process->state() == QProcess::NotRunning) { |
79 QProcess::ProcessError err = m_process->error(); | 73 QProcess::ProcessError err = m_process->error(); |
80 if (err == QProcess::FailedToStart) { | 74 if (err == QProcess::FailedToStart) { |