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

Fixing few shutdown problems #2228

Merged
merged 3 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -514,6 +513,7 @@ void BitcoinApplication::initializeResult(int retval)
});
QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady);
#endif
pollShutdownTimer->start(200);
} else {
quit(); // Exit main loop
}
Expand Down
11 changes: 6 additions & 5 deletions src/qt/pivx/topbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down