Utils: Fix crash if stub fails to start

If the inferior did not start the TerminalInterface did not send an
error up the chain, which meant that the runcontrol does not exit.
This would lead to a crash.

Change-Id: Icf9f8f913d84a9ed6414e15ce3a3587b1580425e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-11-06 13:49:21 +01:00
parent 05ce5ea14d
commit dce08c5b9e

View File

@@ -92,6 +92,7 @@ public:
StubCreator *stubCreator{nullptr};
const bool waitOnExit;
bool didInferiorRun{false};
};
TerminalInterface::TerminalInterface(bool waitOnExit)
@@ -156,6 +157,11 @@ void TerminalInterface::onStubExited()
if (d->inferiorProcessId)
emitFinished(-1, QProcess::CrashExit);
else if (!d->didInferiorRun) {
emitError(QProcess::FailedToStart,
Tr::tr("Failed to start terminal process. The stub exited before the inferior "
"was started."));
}
}
void TerminalInterface::onStubReadyRead()
@@ -176,6 +182,7 @@ void TerminalInterface::onStubReadyRead()
d->envListFile = nullptr;
} else if (out.startsWith("pid ")) {
d->inferiorProcessId = out.mid(4).toInt();
d->didInferiorRun = true;
emit started(d->inferiorProcessId, d->inferiorThreadId);
} else if (out.startsWith("thread ")) { // Windows only
d->inferiorThreadId = out.mid(7).toLongLong();