Skip to content

Commit

Permalink
Fix division by zero in time remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
meshcollider committed Sep 5, 2017
1 parent 50fae68 commit 3b69a08
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/qt/modaloverlay.cpp
Expand Up @@ -99,15 +99,18 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
progressDelta = progressStart-sample.second;
timeDelta = blockProcessTime[0].first - sample.first;
progressPerHour = progressDelta/(double)timeDelta*1000*3600;
remainingMSecs = remainingProgress / progressDelta * timeDelta;
remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta * timeDelta : -1;
break;
}
}
// show progress increase per hour
ui->progressIncreasePerH->setText(QString::number(progressPerHour*100, 'f', 2)+"%");

// show expected remaining time
ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs/1000.0));
if(remainingMSecs >= 0) {
ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0));
} else {
ui->expectedTimeLeft->setText(QObject::tr("unknown"));
}

static const int MAX_SAMPLES = 5000;
if (blockProcessTime.count() > MAX_SAMPLES)
Expand Down Expand Up @@ -169,4 +172,4 @@ void ModalOverlay::closeClicked()
{
showHide(true);
userClosed = true;
}
}

0 comments on commit 3b69a08

Please sign in to comment.