summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-09-02 16:38:40 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-09-03 10:56:19 +0000
commita454b3dc23336365f0900a9986a7e7d0ce28e9ad (patch)
tree4db529188b0eef8bf25ad42a8673de065d136168 /src/libs
parent597750507e1dc4ce3a9de2f653d925b701c131fd (diff)
downloadqt-creator-a454b3dc23336365f0900a9986a7e7d0ce28e9ad.tar.gz
Use QProcess' / process lanuncher's exit code
Change-Id: I802116c45847daf9a647771ee293aef8463fc3c7 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/utils/launchersocket.cpp8
-rw-r--r--src/libs/utils/launchersocket.h1
-rw-r--r--src/libs/utils/qtcprocess.cpp12
3 files changed, 16 insertions, 5 deletions
diff --git a/src/libs/utils/launchersocket.cpp b/src/libs/utils/launchersocket.cpp
index 1efbde047a..3f442066a7 100644
--- a/src/libs/utils/launchersocket.cpp
+++ b/src/libs/utils/launchersocket.cpp
@@ -218,6 +218,8 @@ void CallerHandle::handleError(const ErrorSignal *launcherSignal)
m_processState = QProcess::NotRunning;
m_error = launcherSignal->error();
m_errorString = launcherSignal->errorString();
+ if (m_error == QProcess::FailedToStart)
+ m_exitCode = 255; // This code is being returned by QProcess when FailedToStart error occurred
emit errorOccurred(m_error);
}
@@ -328,6 +330,12 @@ qint64 CallerHandle::processId() const
return m_processId;
}
+int CallerHandle::exitCode() const
+{
+ QTC_ASSERT(isCalledFromCallersThread(), return -1);
+ return m_exitCode;
+}
+
QString CallerHandle::errorString() const
{
QTC_ASSERT(isCalledFromCallersThread(), return {});
diff --git a/src/libs/utils/launchersocket.h b/src/libs/utils/launchersocket.h
index c962a51874..7865c0732a 100644
--- a/src/libs/utils/launchersocket.h
+++ b/src/libs/utils/launchersocket.h
@@ -92,6 +92,7 @@ public:
QByteArray readAllStandardError();
qint64 processId() const;
+ int exitCode() const;
QString errorString() const;
void setErrorString(const QString &str);
diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp
index 35bdeaf877..2f0c79b879 100644
--- a/src/libs/utils/qtcprocess.cpp
+++ b/src/libs/utils/qtcprocess.cpp
@@ -237,6 +237,7 @@ public:
virtual QProcess::ProcessError error() const = 0;
virtual QProcess::ProcessState state() const = 0;
virtual qint64 processId() const = 0;
+ virtual int exitCode() const = 0;
virtual QProcess::ExitStatus exitStatus() const = 0;
virtual QString errorString() const = 0;
virtual void setErrorString(const QString &str) = 0;
@@ -332,6 +333,8 @@ public:
{ return m_process.state(); }
qint64 processId() const override
{ return m_process.processId(); }
+ int exitCode() const override
+ { return m_process.exitCode(); }
QProcess::ExitStatus exitStatus() const override
{ return m_process.exitStatus(); }
QString errorString() const override
@@ -416,6 +419,7 @@ public:
QProcess::ProcessError error() const override { return m_handle->error(); }
QProcess::ProcessState state() const override { return m_handle->state(); }
qint64 processId() const override { return m_handle->processId(); }
+ int exitCode() const override { return m_handle->exitCode(); }
QProcess::ExitStatus exitStatus() const override { return m_handle->exitStatus(); }
QString errorString() const override { return m_handle->errorString(); }
void setErrorString(const QString &str) override { m_handle->setErrorString(str); }
@@ -537,7 +541,6 @@ public:
QEventLoop m_eventLoop;
QtcProcess::Result m_result = QtcProcess::StartFailed;
QProcess::ExitStatus m_exitStatus = QProcess::NormalExit;
- int m_exitCode = -1;
ChannelBuffer m_stdOut;
ChannelBuffer m_stdErr;
ExitCodeInterpreter m_exitCodeInterpreter;
@@ -558,7 +561,6 @@ void QtcProcessPrivate::clearForRun()
m_stdErr.clearForRun();
m_stdErr.codec = m_codec;
m_result = QtcProcess::StartFailed;
- m_exitCode = -1;
m_startFailure = false;
}
@@ -917,7 +919,9 @@ void QtcProcess::setResult(Result result)
int QtcProcess::exitCode() const
{
- return d->m_exitCode;
+ if (d->m_startFailure)
+ return 255; // This code is being returned by QProcess when FailedToStart error occurred
+ return d->m_process->exitCode();
}
@@ -1455,13 +1459,11 @@ void QtcProcessPrivate::slotFinished(int exitCode, QProcess::ExitStatus status)
switch (status) {
case QProcess::NormalExit:
m_result = interpretExitCode(exitCode);
- m_exitCode = exitCode;
break;
case QProcess::CrashExit:
// Was hang detected before and killed?
if (m_result != QtcProcess::Hang)
m_result = QtcProcess::TerminatedAbnormally;
- m_exitCode = -1;
break;
}
m_eventLoop.quit();