@@ -337,6 +337,7 @@ void BitcoinGUI::createActions()
337
337
m_open_wallet_action = new QAction (tr (" Open Wallet" ), this );
338
338
m_open_wallet_action->setEnabled (false );
339
339
m_open_wallet_action->setStatusTip (tr (" Open a wallet" ));
340
+ m_open_wallet_menu = new QMenu (this );
340
341
341
342
m_close_wallet_action = new QAction (tr (" Close Wallet..." ), this );
342
343
m_close_wallet_action->setStatusTip (tr (" Close wallet" ));
@@ -368,13 +369,13 @@ void BitcoinGUI::createActions()
368
369
connect (usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
369
370
connect (usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
370
371
connect (openAction, &QAction::triggered, this , &BitcoinGUI::openClicked);
371
- connect (m_open_wallet_action-> menu () , &QMenu::aboutToShow, [this ] {
372
- m_open_wallet_action-> menu () ->clear ();
372
+ connect (m_open_wallet_menu , &QMenu::aboutToShow, [this ] {
373
+ m_open_wallet_menu ->clear ();
373
374
std::vector<std::string> available_wallets = m_wallet_controller->getWalletsAvailableToOpen ();
374
375
std::vector<std::string> wallets = m_node.listWalletDir ();
375
376
for (const auto & path : wallets) {
376
377
QString name = path.empty () ? QString (" [" +tr (" default wallet" )+" ]" ) : QString::fromStdString (path);
377
- QAction* action = m_open_wallet_action-> menu () ->addAction (name);
378
+ QAction* action = m_open_wallet_menu ->addAction (name);
378
379
379
380
if (std::find (available_wallets.begin (), available_wallets.end (), path) == available_wallets.end ()) {
380
381
// This wallet is already loaded
@@ -410,7 +411,7 @@ void BitcoinGUI::createActions()
410
411
});
411
412
}
412
413
if (wallets.empty ()) {
413
- QAction* action = m_open_wallet_action-> menu () ->addAction (tr (" No wallets available" ));
414
+ QAction* action = m_open_wallet_menu ->addAction (tr (" No wallets available" ));
414
415
action->setEnabled (false );
415
416
}
416
417
});
@@ -634,7 +635,7 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
634
635
m_wallet_controller = wallet_controller;
635
636
636
637
m_open_wallet_action->setEnabled (true );
637
- m_open_wallet_action->setMenu (new QMenu ( this ) );
638
+ m_open_wallet_action->setMenu (m_open_wallet_menu );
638
639
639
640
connect (wallet_controller, &WalletController::walletAdded, this , &BitcoinGUI::addWallet);
640
641
connect (wallet_controller, &WalletController::walletRemoved, this , &BitcoinGUI::removeWallet);
0 commit comments