aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2019-06-18 14:13:03 +0100
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2019-06-18 14:13:04 +0100
commit5224be5a3354e1a22ea4d7f0e40aadfccdf67064 (patch)
treeec15704ca4e94e4b705d55ccf2c07187829fa2c8 /src/qt/bitcoingui.cpp
parent22b6c4ed7562a23e4363e8f0fd889b92c7653d5f (diff)
gui: Fix open wallet menu initialization order
The menu must be created before connecting to aboutToShow signal.
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 1444dddeb1..8388e8d36e 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -337,6 +337,7 @@ void BitcoinGUI::createActions()
m_open_wallet_action = new QAction(tr("Open Wallet"), this);
m_open_wallet_action->setEnabled(false);
m_open_wallet_action->setStatusTip(tr("Open a wallet"));
+ m_open_wallet_menu = new QMenu(this);
m_close_wallet_action = new QAction(tr("Close Wallet..."), this);
m_close_wallet_action->setStatusTip(tr("Close wallet"));
@@ -368,13 +369,13 @@ 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_action->menu(), &QMenu::aboutToShow, [this] {
- m_open_wallet_action->menu()->clear();
+ connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] {
+ m_open_wallet_menu->clear();
std::vector<std::string> available_wallets = m_wallet_controller->getWalletsAvailableToOpen();
std::vector<std::string> wallets = m_node.listWalletDir();
for (const auto& path : wallets) {
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
- QAction* action = m_open_wallet_action->menu()->addAction(name);
+ QAction* action = m_open_wallet_menu->addAction(name);
if (std::find(available_wallets.begin(), available_wallets.end(), path) == available_wallets.end()) {
// This wallet is already loaded
@@ -410,7 +411,7 @@ void BitcoinGUI::createActions()
});
}
if (wallets.empty()) {
- QAction* action = m_open_wallet_action->menu()->addAction(tr("No wallets available"));
+ QAction* action = m_open_wallet_menu->addAction(tr("No wallets available"));
action->setEnabled(false);
}
});
@@ -634,7 +635,7 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
m_wallet_controller = wallet_controller;
m_open_wallet_action->setEnabled(true);
- m_open_wallet_action->setMenu(new QMenu(this));
+ m_open_wallet_action->setMenu(m_open_wallet_menu);
connect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);