Skip to content

Commit

Permalink
GUI: settings information, do not update block num and block hash if …
Browse files Browse the repository at this point in the history
…the screen is not visible.
  • Loading branch information
furszy committed Mar 11, 2021
1 parent cbc5021 commit 02eb781
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/qt/pivx/settings/settingsinformationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <QDir>

#define REQUEST_UPDATE_MN_COUNT 0
#define REQUEST_UPDATE_COUNTS 0

SettingsInformationWidget::SettingsInformationWidget(PIVXGUI* _window,QWidget *parent) :
PWidget(_window,parent),
Expand Down Expand Up @@ -141,6 +141,7 @@ void SettingsInformationWidget::setNumConnections(int count)

void SettingsInformationWidget::setNumBlocks(int count)
{
if (!isVisible()) return;
ui->labelInfoBlockNumber->setText(QString::number(count));
if (clientModel) {
ui->labelInfoBlockTime->setText(clientModel->getLastBlockDate().toString());
Expand Down Expand Up @@ -168,7 +169,7 @@ void SettingsInformationWidget::showEvent(QShowEvent *event)
if (clientModel) {
clientModel->startMasternodesTimer();
// Initial masternodes count value, running in a worker thread to not lock mnmanager mutex in the main thread.
execute(REQUEST_UPDATE_MN_COUNT);
execute(REQUEST_UPDATE_COUNTS);
}
}

Expand All @@ -181,15 +182,17 @@ void SettingsInformationWidget::hideEvent(QHideEvent *event) {

void SettingsInformationWidget::run(int type)
{
if (type == REQUEST_UPDATE_MN_COUNT) {
if (type == REQUEST_UPDATE_COUNTS) {
QMetaObject::invokeMethod(this, "setMasternodeCount",
Qt::QueuedConnection, Q_ARG(QString, clientModel->getMasternodesCount()));
QMetaObject::invokeMethod(this, "setNumBlocks",
Qt::QueuedConnection, Q_ARG(int, clientModel->getLastBlockProcessedHeight()));
}
}

void SettingsInformationWidget::onError(QString error, int type)
{
if (type == REQUEST_UPDATE_MN_COUNT) {
if (type == REQUEST_UPDATE_COUNTS) {
setMasternodeCount(tr("No available data"));
}
}
Expand Down

0 comments on commit 02eb781

Please sign in to comment.