summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-03-17 09:23:33 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-05-13 20:25:27 +0000
commitc257e518c161122625dc1b5e62742b6195d67f7a (patch)
tree8248a91593e1f44e62ae8518774460fcece30398
parent45a03fc50662e0977eecf57d62cbe9d8348eb903 (diff)
QProcessPrivate: remove the member variable "crashed"
It was only used to later set exitStatus = CrashExit, so simply do it early. Drive-by removal of a magic numeric literal in the middle of the source code. It's still magic, but at least we avoid accidentally making typos. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d4176a5d87641 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/corelib/io/qprocess.cpp4
-rw-r--r--src/corelib/io/qprocess_p.h1
-rw-r--r--src/corelib/io/qprocess_unix.cpp4
-rw-r--r--src/corelib/io/qprocess_win.cpp11
4 files changed, 11 insertions, 9 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 6764273cb7..116bb78b8a 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1145,10 +1145,8 @@ void QProcessPrivate::processFinished()
cleanup();
- if (crashed) {
- exitStatus = QProcess::CrashExit;
+ if (exitStatus == QProcess::CrashExit)
setErrorAndEmit(QProcess::Crashed);
- }
// we received EOF now:
emit q->readChannelFinished();
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 929c06480b..e6f279d5f3 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -327,7 +327,6 @@ public:
int exitCode = 0;
QProcess::ExitStatus exitStatus = QProcess::NormalExit;
- bool crashed = false;
bool waitForStarted(const QDeadlineTimer &deadline);
bool waitForReadyRead(const QDeadlineTimer &deadline);
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 9fbf869455..3ffe8b28e2 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -896,7 +896,7 @@ void QProcessPrivate::waitForDeadChild()
EINTR_LOOP(ret, forkfd_wait(forkfd, &info, nullptr));
exitCode = info.status;
- crashed = info.code != CLD_EXITED;
+ exitStatus = info.code == CLD_EXITED ? QProcess::NormalExit : QProcess::CrashExit;
delete stateNotifier;
stateNotifier = nullptr;
@@ -906,7 +906,7 @@ void QProcessPrivate::waitForDeadChild()
#if defined QPROCESS_DEBUG
qDebug() << "QProcessPrivate::waitForDeadChild() dead with exitCode"
- << exitCode << ", crashed?" << crashed;
+ << exitCode << ", crashed?" << (info.code != CLD_EXITED);
#endif
}
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 04c67b4070..650e9038cc 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -28,6 +28,8 @@
QT_BEGIN_NAMESPACE
+constexpr UINT KillProcessExitCode = 0xf291;
+
using namespace Qt::StringLiterals;
QProcessEnvironment QProcessEnvironment::systemEnvironment()
@@ -632,7 +634,7 @@ void QProcessPrivate::terminateProcess()
void QProcessPrivate::killProcess()
{
if (pid)
- TerminateProcess(pid->hProcess, 0xf291);
+ TerminateProcess(pid->hProcess, KillProcessExitCode);
}
bool QProcessPrivate::waitForStarted(const QDeadlineTimer &)
@@ -782,8 +784,11 @@ void QProcessPrivate::findExitCode()
Q_ASSERT(pid);
if (GetExitCodeProcess(pid->hProcess, &theExitCode)) {
exitCode = theExitCode;
- crashed = (exitCode == 0xf291 // our magic number, see killProcess
- || (theExitCode >= 0x80000000 && theExitCode < 0xD0000000));
+ if (exitCode == KillProcessExitCode
+ || (theExitCode >= 0x80000000 && theExitCode < 0xD0000000))
+ exitStatus = QProcess::CrashExit;
+ else
+ exitStatus = QProcess::NormalExit;
}
}