forked from qt-creator/qt-creator
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:
@@ -92,6 +92,7 @@ public:
|
|||||||
StubCreator *stubCreator{nullptr};
|
StubCreator *stubCreator{nullptr};
|
||||||
|
|
||||||
const bool waitOnExit;
|
const bool waitOnExit;
|
||||||
|
bool didInferiorRun{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
TerminalInterface::TerminalInterface(bool waitOnExit)
|
TerminalInterface::TerminalInterface(bool waitOnExit)
|
||||||
@@ -156,6 +157,11 @@ void TerminalInterface::onStubExited()
|
|||||||
|
|
||||||
if (d->inferiorProcessId)
|
if (d->inferiorProcessId)
|
||||||
emitFinished(-1, QProcess::CrashExit);
|
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()
|
void TerminalInterface::onStubReadyRead()
|
||||||
@@ -176,6 +182,7 @@ void TerminalInterface::onStubReadyRead()
|
|||||||
d->envListFile = nullptr;
|
d->envListFile = nullptr;
|
||||||
} else if (out.startsWith("pid ")) {
|
} else if (out.startsWith("pid ")) {
|
||||||
d->inferiorProcessId = out.mid(4).toInt();
|
d->inferiorProcessId = out.mid(4).toInt();
|
||||||
|
d->didInferiorRun = true;
|
||||||
emit started(d->inferiorProcessId, d->inferiorThreadId);
|
emit started(d->inferiorProcessId, d->inferiorThreadId);
|
||||||
} else if (out.startsWith("thread ")) { // Windows only
|
} else if (out.startsWith("thread ")) { // Windows only
|
||||||
d->inferiorThreadId = out.mid(7).toLongLong();
|
d->inferiorThreadId = out.mid(7).toLongLong();
|
||||||
|
Reference in New Issue
Block a user