Skip to content

Commit 1a61563

Browse files
hebastovijaydasmp
authored andcommitted
Merge bitcoin-core/gui#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
1 parent e407cf5 commit 1a61563

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/qt/bitcoingui.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ void BitcoinGUI::createActions()
517517
connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
518518
connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
519519
connect(openAction, &QAction::triggered, this, &BitcoinGUI::openClicked);
520-
connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] {
520+
connect(m_open_wallet_menu, &QMenu::aboutToShow, m_wallet_controller, [this] {
521521
m_open_wallet_menu->clear();
522522
for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
523523
const std::string& path = i.first;
@@ -533,7 +533,7 @@ void BitcoinGUI::createActions()
533533
continue;
534534
}
535535

536-
connect(action, &QAction::triggered, [this, path] {
536+
connect(action, &QAction::triggered, m_wallet_controller, [this, path] {
537537
auto activity = new OpenWalletActivity(m_wallet_controller, this);
538538
connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
539539
connect(activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection);
@@ -545,7 +545,7 @@ void BitcoinGUI::createActions()
545545
action->setEnabled(false);
546546
}
547547
});
548-
connect(m_restore_wallet_action, &QAction::triggered, [this] {
548+
connect(m_restore_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
549549
//: Name of the wallet data file format.
550550
QString name_data_file = tr("Wallet Data");
551551

@@ -571,16 +571,16 @@ void BitcoinGUI::createActions()
571571
auto backup_file_path = fs::PathFromString(backup_file.toStdString());
572572
activity->restore(backup_file_path, wallet_name.toStdString());
573573
});
574-
connect(m_close_wallet_action, &QAction::triggered, [this] {
574+
connect(m_close_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
575575
m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
576576
});
577-
connect(m_create_wallet_action, &QAction::triggered, [this] {
577+
connect(m_create_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
578578
auto activity = new CreateWalletActivity(m_wallet_controller, this);
579579
connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
580580
connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
581581
activity->create();
582582
});
583-
connect(m_close_all_wallets_action, &QAction::triggered, [this] {
583+
connect(m_close_all_wallets_action, &QAction::triggered, m_wallet_controller, [this] {
584584
m_wallet_controller->closeAllWallets(this);
585585
});
586586

@@ -892,7 +892,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
892892

893893
m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool());
894894
} else {
895-
if(trayIconMenu)
895+
// Shutdown requested, disable menus
896+
if (trayIconMenu)
896897
{
897898
// Disable context menu on tray icon
898899
trayIconMenu->clear();
@@ -906,6 +907,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
906907
}
907908
#endif // ENABLE_WALLET
908909
unitDisplayControl->setOptionsModel(nullptr);
910+
// Disable top bar menu actions
911+
appMenuBar->clear();
909912

910913
#ifdef Q_OS_MACOS
911914
if(dockIconMenu)

0 commit comments

Comments
 (0)