aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorJohn Moffett <john.moff@gmail.com>2022-12-30 16:09:56 -0500
committerJohn Moffett <john.moff@gmail.com>2023-01-08 19:31:56 -0500
commit9a1d73fdffa4f35e33bc187ac9b3afbba28b1950 (patch)
tree6bb45b53a01b6d1725bc06086d4c97132dc5e72b /src/qt/bitcoingui.cpp
parent65de8eeeca29e71378aa34602b287ab921b040e4 (diff)
downloadbitcoin-9a1d73fdffa4f35e33bc187ac9b3afbba28b1950.tar.xz
Fix segfault when shutdown during wallet open
If you open a wallet and send a shutdown signal during that process, the GUI will segfault due to some queued wallet events happening after the wallet controller is deleted. This is a minimal fix for those issues.
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index a0731b337a..47e4f9978d 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -680,6 +680,10 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
GUIUtil::ExceptionSafeConnect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);
+ connect(wallet_controller, &WalletController::destroyed, this, [this] {
+ // wallet_controller gets destroyed manually, but it leaves our member copy dangling
+ m_wallet_controller = nullptr;
+ });
auto activity = new LoadWalletsActivity(m_wallet_controller, this);
activity->load();
@@ -692,7 +696,7 @@ WalletController* BitcoinGUI::getWalletController()
void BitcoinGUI::addWallet(WalletModel* walletModel)
{
- if (!walletFrame) return;
+ if (!walletFrame || !m_wallet_controller) return;
WalletView* wallet_view = new WalletView(walletModel, platformStyle, walletFrame);
if (!walletFrame->addView(wallet_view)) return;
@@ -742,7 +746,7 @@ void BitcoinGUI::removeWallet(WalletModel* walletModel)
void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
{
- if (!walletFrame) return;
+ if (!walletFrame || !m_wallet_controller) return;
walletFrame->setCurrentWallet(wallet_model);
for (int index = 0; index < m_wallet_selector->count(); ++index) {
if (m_wallet_selector->itemData(index).value<WalletModel*>() == wallet_model) {