aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph/processcommandexecutor.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-11-17 15:15:21 +0100
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2015-11-17 14:34:48 +0000
commit624970dd1373979c214ed072ea9e2d1319c2d07d (patch)
treebed76fb529ca341a2f133f74815deeb954d0b947 /src/lib/corelib/buildgraph/processcommandexecutor.cpp
parenteac735bc33d9f09437fe89c6d11cd5ade013b7bc (diff)
Allow more fine-grained error reporting in ProcessResult.
We achieve this by forwarding QProcess::ProcessError instead of QProcess::ExitStatus. Change-Id: Id4b9ac7facbb92281e0a11da635131145114be9d Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/lib/corelib/buildgraph/processcommandexecutor.cpp')
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
index 1d77bab6c..3db3e496b 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
@@ -62,7 +62,7 @@ ProcessCommandExecutor::ProcessCommandExecutor(const Logger &logger, QObject *pa
: AbstractCommandExecutor(logger, parent)
{
connect(&m_process, SIGNAL(error(QProcess::ProcessError)), SLOT(onProcessError()));
- connect(&m_process, SIGNAL(finished(int)), SLOT(onProcessFinished(int)));
+ connect(&m_process, SIGNAL(finished(int)), SLOT(onProcessFinished()));
}
void ProcessCommandExecutor::doSetup()
@@ -196,7 +196,7 @@ QString ProcessCommandExecutor::filterProcessOutput(const QByteArray &_output,
return filteredOutput.toString();
}
-void ProcessCommandExecutor::sendProcessOutput(bool success)
+void ProcessCommandExecutor::sendProcessOutput()
{
ProcessResult result;
result.d->executableFilePath = m_program;
@@ -205,8 +205,8 @@ void ProcessCommandExecutor::sendProcessOutput(bool success)
if (result.workingDirectory().isEmpty())
result.d->workingDirectory = QDir::currentPath();
result.d->exitCode = m_process.exitCode();
- result.d->exitStatus = m_process.exitStatus();
- result.d->success = success;
+ result.d->error = m_process.error();
+ QString errorString = m_process.errorString();
QString tmp = filterProcessOutput(m_process.readAllStandardOutput(),
processCommand()->stdoutFilterFunction());
@@ -222,8 +222,20 @@ void ProcessCommandExecutor::sendProcessOutput(bool success)
tmp.chop(1);
result.d->stdErr = tmp.split(QLatin1Char('\n'));
}
-
+ const bool processError = result.error() != QProcess::UnknownError;
+ const bool failureExit = quint32(m_process.exitCode())
+ > quint32(processCommand()->maxExitCode());
+ result.d->success = !processError && !failureExit;
emit reportProcessResult(result);
+
+ if (Q_UNLIKELY(processError)) {
+ emit finished(ErrorInfo(errorString));
+ } else if (Q_UNLIKELY(failureExit)) {
+ emit finished(ErrorInfo(Tr::tr("Process failed with exit code %1.")
+ .arg(m_process.exitCode())));
+ } else {
+ emit finished();
+ }
}
void ProcessCommandExecutor::onProcessError()
@@ -254,20 +266,10 @@ void ProcessCommandExecutor::onProcessError()
}
}
-void ProcessCommandExecutor::onProcessFinished(int exitCode)
+void ProcessCommandExecutor::onProcessFinished()
{
removeResponseFile();
- const bool crashed = m_process.exitStatus() == QProcess::CrashExit;
- const bool errorOccurred = crashed
- || quint32(exitCode) > quint32(processCommand()->maxExitCode());
- sendProcessOutput(!errorOccurred);
-
- if (Q_UNLIKELY(crashed))
- emit finished(ErrorInfo(Tr::tr("Process crashed.")));
- else if (Q_UNLIKELY(errorOccurred))
- emit finished(ErrorInfo(Tr::tr("Process failed with exit code %1.").arg(exitCode)));
- else
- emit finished();
+ sendProcessOutput();
}
void ProcessCommandExecutor::doReportCommandDescription()