summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-04-29 16:52:58 +0200
committerTobias Hunger <tobias.hunger@qt.io>2016-05-11 10:04:38 +0000
commitddefe062c73e35def585f8fc6c90a4f18e47c0f4 (patch)
tree03c3aecc501c03b92e259fe0ae1c4d472033b7e5 /src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
parent1a248b1b932e2c7c42e25993d921e78c52aa4bcf (diff)
downloadqt-creator-ddefe062c73e35def585f8fc6c90a4f18e47c0f4.tar.gz
Fix up QProcess::waitForFinished()
waitForFinish returns false if the process is no longer running at the time of the call. Handle that throughout the codebase. Change-Id: Ia7194095454e82efbd4eb88f2d55926bdd09e094 Reviewed-by: hjk <hjk@theqtcompany.com>
Diffstat (limited to 'src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp')
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
index fa1e83cdab..59487384c1 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp
@@ -28,8 +28,8 @@
#include "customwizardparameters.h"
#include <utils/hostosinfo.h>
+#include <utils/synchronousprocess.h>
-#include <QProcess>
#include <QDir>
#include <QFileInfo>
#include <QDebug>
@@ -83,7 +83,7 @@ static bool
const QMap<QString, QString> &fieldMap,
QString *stdOut /* = 0 */, QString *errorMessage)
{
- QProcess process;
+ Utils::SynchronousProcess process;
const QString binary = script.front();
QStringList arguments;
const int binarySize = script.size();
@@ -107,32 +107,23 @@ static bool
arguments.push_back(value);
}
process.setWorkingDirectory(workingDirectory);
+ process.setTimeoutS(30);
if (CustomWizard::verbose())
qDebug("In %s, running:\n%s\n%s\n", qPrintable(workingDirectory),
qPrintable(binary),
qPrintable(arguments.join(QLatin1Char(' '))));
- process.start(binary, arguments);
- if (!process.waitForStarted()) {
- *errorMessage = QString::fromLatin1("Unable to start generator script %1: %2").
- arg(binary, process.errorString());
- return false;
- }
- if (!process.waitForFinished()) {
- *errorMessage = QString::fromLatin1("Generator script %1 timed out").arg(binary);
- return false;
- }
- if (process.exitStatus() != QProcess::NormalExit) {
- *errorMessage = QString::fromLatin1("Generator script %1 crashed").arg(binary);
- return false;
- }
- if (process.exitCode() != 0) {
- const QString stdErr = QString::fromLocal8Bit(process.readAllStandardError());
- *errorMessage = QString::fromLatin1("Generator script %1 returned %2 (%3)").
- arg(binary).arg(process.exitCode()).arg(stdErr);
+ Utils::SynchronousProcessResponse response = process.run(binary, arguments);
+ if (response.result != Utils::SynchronousProcessResponse::Finished) {
+ *errorMessage = QString::fromLatin1("Generator script failed: %1")
+ .arg(response.exitMessage(binary, 30));
+ if (!response.stdErr.isEmpty()) {
+ errorMessage->append(QLatin1Char('\n'));
+ errorMessage->append(response.stdErr);
+ }
return false;
}
if (stdOut) {
- *stdOut = QString::fromLocal8Bit(process.readAllStandardOutput());
+ *stdOut = response.stdOut;
stdOut->remove(QLatin1Char('\r'));
if (CustomWizard::verbose())
qDebug("Output: '%s'\n", qPrintable(*stdOut));