forked from qt-creator/qt-creator
Utils: Fix runBlocking
* result is initialized to StartFailed, so after executing, we should always set the result, unless previously set to Hang. If the process really fails to start, we return earlier. * Setting m_maxHangTimerCount to INT_MAX is bad, since it is later multiplied by 1000 (the original value is in seconds), but still remains an int, so we get -1000... Change-Id: Ie990105894fe223a93ece29df4574592a122f94b Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
9d74b995fb
commit
94e08b9adc
@@ -297,12 +297,12 @@ void SynchronousProcess::setTimeoutS(int timeoutS)
|
||||
if (timeoutS > 0)
|
||||
d->m_maxHangTimerCount = qMax(2, timeoutS);
|
||||
else
|
||||
d->m_maxHangTimerCount = INT_MAX;
|
||||
d->m_maxHangTimerCount = INT_MAX / 1000;
|
||||
}
|
||||
|
||||
int SynchronousProcess::timeoutS() const
|
||||
{
|
||||
return d->m_maxHangTimerCount == INT_MAX ? -1 : d->m_maxHangTimerCount;
|
||||
return d->m_maxHangTimerCount == (INT_MAX / 1000) ? -1 : d->m_maxHangTimerCount;
|
||||
}
|
||||
|
||||
void SynchronousProcess::setCodec(QTextCodec *c)
|
||||
@@ -476,7 +476,7 @@ SynchronousProcessResponse SynchronousProcess::runBlocking(const QString &binary
|
||||
|
||||
QTC_ASSERT(d->m_process.state() == QProcess::NotRunning, return d->m_result);
|
||||
d->m_result.exitCode = d->m_process.exitCode();
|
||||
if (d->m_result.result != SynchronousProcessResponse::StartFailed) {
|
||||
if (d->m_result.result == SynchronousProcessResponse::StartFailed) {
|
||||
if (d->m_process.exitStatus() != QProcess::NormalExit)
|
||||
d->m_result.result = SynchronousProcessResponse::TerminatedAbnormally;
|
||||
else
|
||||
|
Reference in New Issue
Block a user