From 7066e8996d0ac090535cc97cdcb54a219986460f Mon Sep 17 00:00:00 2001 From: furszy Date: Fri, 6 Oct 2023 10:42:05 -0300 Subject: [PATCH 1/2] gui: provide wallet controller context to wallet actions Addressing potential crashes during shutdown. The most noticeable one can be triggered by hovering over the wallet list as the app shuts down. --- src/qt/bitcoingui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 171b50d8093dc..96cc5a3bf0a6f 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -392,7 +392,7 @@ void BitcoinGUI::createActions() connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses); connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses); connect(openAction, &QAction::triggered, this, &BitcoinGUI::openClicked); - connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] { + connect(m_open_wallet_menu, &QMenu::aboutToShow, m_wallet_controller, [this] { m_open_wallet_menu->clear(); for (const std::pair& i : m_wallet_controller->listWalletDir()) { const std::string& path = i.first; @@ -409,7 +409,7 @@ void BitcoinGUI::createActions() continue; } - connect(action, &QAction::triggered, [this, path] { + connect(action, &QAction::triggered, m_wallet_controller, [this, path] { auto activity = new OpenWalletActivity(m_wallet_controller, this); connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection); connect(activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection); @@ -421,7 +421,7 @@ void BitcoinGUI::createActions() action->setEnabled(false); } }); - connect(m_restore_wallet_action, &QAction::triggered, [this] { + connect(m_restore_wallet_action, &QAction::triggered, m_wallet_controller, [this] { //: Name of the wallet data file format. QString name_data_file = tr("Wallet Data"); @@ -447,14 +447,14 @@ void BitcoinGUI::createActions() auto backup_file_path = fs::PathFromString(backup_file.toStdString()); activity->restore(backup_file_path, wallet_name.toStdString()); }); - connect(m_close_wallet_action, &QAction::triggered, [this] { + connect(m_close_wallet_action, &QAction::triggered, m_wallet_controller, [this] { m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this); }); connect(m_create_wallet_action, &QAction::triggered, this, &BitcoinGUI::createWallet); - connect(m_close_all_wallets_action, &QAction::triggered, [this] { + connect(m_close_all_wallets_action, &QAction::triggered, m_wallet_controller, [this] { m_wallet_controller->closeAllWallets(this); }); - connect(m_migrate_wallet_action, &QAction::triggered, [this] { + connect(m_migrate_wallet_action, &QAction::triggered, m_wallet_controller, [this] { auto activity = new MigrateWalletActivity(m_wallet_controller, this); connect(activity, &MigrateWalletActivity::migrated, this, &BitcoinGUI::setCurrentWallet); activity->migrate(walletFrame->currentWalletModel()); From 8b6470a90652fcffc45b8d7998af7c8ad6251332 Mon Sep 17 00:00:00 2001 From: furszy Date: Fri, 13 Oct 2023 17:27:24 -0300 Subject: [PATCH 2/2] gui: disable top bar menu actions during shutdown Opening the top bar menu when the app is being destroyed freezes the GUI shutdown process for no reason. No menu action can be executed. Note: This behavior is consistent with how the tray icon menu is cleared too. --- src/qt/bitcoingui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 96cc5a3bf0a6f..720f5584d6dcb 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -650,7 +650,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool()); } else { - if(trayIconMenu) + // Shutdown requested, disable menus + if (trayIconMenu) { // Disable context menu on tray icon trayIconMenu->clear(); @@ -664,6 +665,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH } #endif // ENABLE_WALLET unitDisplayControl->setOptionsModel(nullptr); + // Disable top bar menu actions + appMenuBar->clear(); } }