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>
This commit is contained in:
parent
45a03fc506
commit
c257e518c1
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user