SynchronousProcess: Make runBlocking more robust

Make runBlocking handle the case where the process starts up too fast
for waitForStarted.

Change-Id: Id8f3522c7c23bc8d7cdbbc94da6fa6c0b8e45454
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Tobias Hunger
2018-07-05 11:22:34 +02:00
parent 5c81a65422
commit 0ac5e9c30e

View File

@@ -488,7 +488,8 @@ SynchronousProcessResponse SynchronousProcess::runBlocking(const QString &binary
// event loop in that case.
d->m_binary = binary;
d->m_process.start(binary, args, QIODevice::ReadOnly);
if (!d->m_process.waitForStarted(d->m_maxHangTimerCount * 1000)) {
if (!d->m_process.waitForStarted(d->m_maxHangTimerCount * 1000)
&& d->m_process.state() == QProcess::NotRunning) {
d->m_result.result = SynchronousProcessResponse::StartFailed;
return d->m_result;
}