From 21d56e7e60beca7fad89db9fd312d50b91e51e77 Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 12 Jan 2021 10:45:22 -0300 Subject: [PATCH 1/3] [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 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; From 196116389bb899af53d734a581dd48e4e82f164d Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 3 Mar 2021 13:02:20 -0300 Subject: [PATCH 2/3] qt: Poll ShutdownTimer after init is done --- src/qt/pivx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } From c853471fbc7ea41b7c36e6fafdbbff76789f088f Mon Sep 17 00:00:00 2001 From: furszy Date: Wed, 3 Mar 2021 13:06:40 -0300 Subject: [PATCH 3/3] init: shutdown and return early if ActivateBestChain() fails. --- src/init.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);