From f17d80d009b1b95a56c8c4ddd62ec000cd806a06 Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 12 Jan 2021 10:45:22 -0300 Subject: [PATCH] [GUI] Topbar: don't try to poll for data if shutdown was requested. --- src/qt/pivx/topbar.cpp | 11 ++++++----- src/qt/walletmodel.cpp | 6 ++++++ src/qt/walletmodel.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/qt/pivx/topbar.cpp b/src/qt/pivx/topbar.cpp index 2b9e9f02a8394..52b3d0e346310 100644 --- a/src/qt/pivx/topbar.cpp +++ b/src/qt/pivx/topbar.cpp @@ -443,12 +443,13 @@ void TopBar::setStakingStatusActive(bool fActive) } void TopBar::updateStakingStatus() { - setStakingStatusActive(walletModel && - !walletModel->isWalletLocked() && - walletModel->isStakingStatusActive()); + if (walletModel && !walletModel->isShutdownRequested()) { + setStakingStatusActive(!walletModel->isWalletLocked() && + walletModel->isStakingStatusActive()); - // Taking advantage of this timer to update Tor status if needed. - updateTorIcon(); + // Taking advantage of this timer to update Tor status if needed. + updateTorIcon(); + } } void TopBar::setNumConnections(int count) diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 97a9fdbe59c85..13deb65391991 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -11,6 +11,7 @@ #include "optionsmodel.h" #include "recentrequeststablemodel.h" #include "transactiontablemodel.h" +#include "init.h" // for ShutdownRequested(). Future: move to an interface wrapper #include "base58.h" #include "coincontrol.h" @@ -67,6 +68,11 @@ bool WalletModel::isRegTestNetwork() const return Params().IsRegTestNet(); } +bool WalletModel::isShutdownRequested() +{ + return ShutdownRequested(); +} + bool WalletModel::isColdStakingNetworkelyEnabled() const { return !sporkManager.IsSporkActive(SPORK_19_COLDSTAKING_MAINTENANCE); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 02d3a43cfc146..28c77043ce534 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -152,6 +152,7 @@ class WalletModel : public QObject bool isTestNetwork() const; bool isRegTestNetwork() const; + bool isShutdownRequested(); /** Whether cold staking is enabled or disabled in the network **/ bool isColdStakingNetworkelyEnabled() const; bool isSaplingInMaintenance() const;