Skip to content

Commit 9270453

Browse files
committed
Merge #765: Fix wallet list hover crash on shutdown
8b6470a gui: disable top bar menu actions during shutdown (furszy) 7066e89 gui: provide wallet controller context to wallet actions (furszy) Pull request description: Small follow-up to #751. Fixes another crash cause during shutdown. Which occurs when the user hovers over the wallets list. Future Note: This surely happen in other places as well, we should re-work the way we connect signals. Register lambas without any precaution can leave dangling pointers. ACKs for top commit: hebasto: ACK 8b6470a, I've tested each commit separately on macOS Sonoma 14.0 (Apple M1). Tree-SHA512: 6fbd1bcd6717a8c1633beb9371463ed22422f929cccf9b791ee292c5364134c501e099329cf77a06b74a84c64c1c3d22539199ec49ccd74b3950036316c0dab3
2 parents 22fa1f4 + 8b6470a commit 9270453

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/qt/bitcoingui.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void BitcoinGUI::createActions()
392392
connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
393393
connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
394394
connect(openAction, &QAction::triggered, this, &BitcoinGUI::openClicked);
395-
connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] {
395+
connect(m_open_wallet_menu, &QMenu::aboutToShow, m_wallet_controller, [this] {
396396
m_open_wallet_menu->clear();
397397
for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
398398
const std::string& path = i.first;
@@ -409,7 +409,7 @@ void BitcoinGUI::createActions()
409409
continue;
410410
}
411411

412-
connect(action, &QAction::triggered, [this, path] {
412+
connect(action, &QAction::triggered, m_wallet_controller, [this, path] {
413413
auto activity = new OpenWalletActivity(m_wallet_controller, this);
414414
connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
415415
connect(activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection);
@@ -421,7 +421,7 @@ void BitcoinGUI::createActions()
421421
action->setEnabled(false);
422422
}
423423
});
424-
connect(m_restore_wallet_action, &QAction::triggered, [this] {
424+
connect(m_restore_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
425425
//: Name of the wallet data file format.
426426
QString name_data_file = tr("Wallet Data");
427427

@@ -447,14 +447,14 @@ void BitcoinGUI::createActions()
447447
auto backup_file_path = fs::PathFromString(backup_file.toStdString());
448448
activity->restore(backup_file_path, wallet_name.toStdString());
449449
});
450-
connect(m_close_wallet_action, &QAction::triggered, [this] {
450+
connect(m_close_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
451451
m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
452452
});
453453
connect(m_create_wallet_action, &QAction::triggered, this, &BitcoinGUI::createWallet);
454-
connect(m_close_all_wallets_action, &QAction::triggered, [this] {
454+
connect(m_close_all_wallets_action, &QAction::triggered, m_wallet_controller, [this] {
455455
m_wallet_controller->closeAllWallets(this);
456456
});
457-
connect(m_migrate_wallet_action, &QAction::triggered, [this] {
457+
connect(m_migrate_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
458458
auto activity = new MigrateWalletActivity(m_wallet_controller, this);
459459
connect(activity, &MigrateWalletActivity::migrated, this, &BitcoinGUI::setCurrentWallet);
460460
activity->migrate(walletFrame->currentWalletModel());
@@ -650,7 +650,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
650650

651651
m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool());
652652
} else {
653-
if(trayIconMenu)
653+
// Shutdown requested, disable menus
654+
if (trayIconMenu)
654655
{
655656
// Disable context menu on tray icon
656657
trayIconMenu->clear();
@@ -664,6 +665,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
664665
}
665666
#endif // ENABLE_WALLET
666667
unitDisplayControl->setOptionsModel(nullptr);
668+
// Disable top bar menu actions
669+
appMenuBar->clear();
667670
}
668671
}
669672

0 commit comments

Comments
 (0)