Skip to content

Commit 3b69a08

Browse files
committed
Fix division by zero in time remaining
1 parent 50fae68 commit 3b69a08

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/qt/modaloverlay.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,18 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
9999
progressDelta = progressStart-sample.second;
100100
timeDelta = blockProcessTime[0].first - sample.first;
101101
progressPerHour = progressDelta/(double)timeDelta*1000*3600;
102-
remainingMSecs = remainingProgress / progressDelta * timeDelta;
102+
remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta * timeDelta : -1;
103103
break;
104104
}
105105
}
106106
// show progress increase per hour
107107
ui->progressIncreasePerH->setText(QString::number(progressPerHour*100, 'f', 2)+"%");
108108

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

112115
static const int MAX_SAMPLES = 5000;
113116
if (blockProcessTime.count() > MAX_SAMPLES)
@@ -169,4 +172,4 @@ void ModalOverlay::closeClicked()
169172
{
170173
showHide(true);
171174
userClosed = true;
172-
}
175+
}

0 commit comments

Comments
 (0)