diff --git a/src/init.cpp b/src/init.cpp index 74bd55904af56..10e6fea7187d4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1793,8 +1793,11 @@ bool AppInitMain() // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; - if (!ActivateBestChain(state)) + if (!ActivateBestChain(state)) { strErrors << "Failed to connect best block"; + StartShutdown(); + return false; + } // update g_best_block if needed { LOCK(g_best_block_mutex); diff --git a/src/qt/pivx.cpp b/src/qt/pivx.cpp index 0d31a5c7843ba..c2b5d50732a0c 100644 --- a/src/qt/pivx.cpp +++ b/src/qt/pivx.cpp @@ -373,7 +373,6 @@ void BitcoinApplication::createWindow(const NetworkStyle* networkStyle) pollShutdownTimer = new QTimer(window); connect(pollShutdownTimer, &QTimer::timeout, window, &PIVXGUI::detectShutdown); - pollShutdownTimer->start(200); } void BitcoinApplication::createSplashScreen(const NetworkStyle* networkStyle) @@ -514,6 +513,7 @@ void BitcoinApplication::initializeResult(int retval) }); QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady); #endif + pollShutdownTimer->start(200); } else { quit(); // Exit main loop } 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 c7eaf5b7b4738..bfb3d7673550b 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 63b1aaa3e50aa..3ad51df807806 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -151,6 +151,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;