Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt: Fixing division by zero in time remaining #11237

Merged
merged 2 commits into from
Sep 7, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/qt/modaloverlay.cpp
Original file line number Diff line number Diff line change
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
Copy link
Member

@laanwj laanwj Sep 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you remove this comment intentionally?
Edit: oh! it's re-added in the commit after this. That's a bit strange :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah must have just been a bad commit split, sorry about that

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;
}
}