Utils: Consider timeout of 0 for SynchronousProcess as infinite

Makes much more sense than plain 0.

Fixes Git interactive rebase that should have no timeout.

Change-Id: I48b4d4dc35c8e5ed13e074d431d05d6795eb8797
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-05-27 21:56:38 +03:00
committed by Orgad Shaneh
parent 1ca649994c
commit d0f9ed7ea4

View File

@@ -270,7 +270,7 @@ SynchronousProcess::~SynchronousProcess()
void SynchronousProcess::setTimeoutS(int timeoutS)
{
if (timeoutS >= 0)
if (timeoutS > 0)
d->m_maxHangTimerCount = qMax(2, timeoutS);
else
d->m_maxHangTimerCount = INT_MAX;
@@ -599,7 +599,8 @@ bool SynchronousProcess::readDataFromProcess(QProcess &p, int timeoutS,
bool finished = false;
bool hasData = false;
do {
finished = p.state() == QProcess::NotRunning || p.waitForFinished(timeoutS * 1000);
finished = p.state() == QProcess::NotRunning
|| p.waitForFinished(timeoutS > 0 ? timeoutS * 1000 : -1);
hasData = false;
// First check 'stdout'
if (p.bytesAvailable()) { // applies to readChannel() only