@@ -77,6 +77,14 @@ std::map<std::string, bool> WalletController::listWalletDir() const
7777 return wallets;
7878}
7979
80+ void WalletController::removeWallet (WalletModel* wallet_model)
81+ {
82+ // Once the wallet is successfully removed from the node, the model will emit the 'WalletModel::unload' signal.
83+ // This signal is already connected and will complete the removal of the view from the GUI.
84+ // Look at 'WalletController::getOrCreateWallet' for the signal connection.
85+ wallet_model->wallet ().remove ();
86+ }
87+
8088void WalletController::closeWallet (WalletModel* wallet_model, QWidget* parent)
8189{
8290 QMessageBox box (parent);
@@ -87,10 +95,7 @@ void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
8795 box.setDefaultButton (QMessageBox::Yes);
8896 if (box.exec () != QMessageBox::Yes) return ;
8997
90- // First remove wallet from node.
91- wallet_model->wallet ().remove ();
92- // Now release the model.
93- removeAndDeleteWallet (wallet_model);
98+ removeWallet (wallet_model);
9499}
95100
96101void WalletController::closeAllWallets (QWidget* parent)
@@ -103,11 +108,8 @@ void WalletController::closeAllWallets(QWidget* parent)
103108
104109 QMutexLocker locker (&m_mutex);
105110 for (WalletModel* wallet_model : m_wallets) {
106- wallet_model->wallet ().remove ();
107- Q_EMIT walletRemoved (wallet_model);
108- delete wallet_model;
111+ removeWallet (wallet_model);
109112 }
110- m_wallets.clear ();
111113}
112114
113115WalletModel* WalletController::getOrCreateWallet (std::unique_ptr<interfaces::Wallet> wallet)
0 commit comments