Skip to content

Commit c6be968

Browse files
Merge #6881: revert: Revert "merge bitcoin-core/gui#835: Fix crash when closing wallet"
826221b revert: Revert "merge bitcoin-core/gui#835: Fix crash when closing wallet" (UdjinM6) Pull request description: ## Issue being fixed or feature implemented This reverts commit 20763f1 from #6829. The issue that was meant to be fixed by that backport does not exist in our codebase yet, see bitcoin-core/gui#835 (review). Even worse, backporting it too early created an issue where wallets would not be removed from gui while being removed in background. ## What was done? revert it ## How Has This Been Tested? open multiple wallets, try closing one of them. develop: no visual changes, feels like "Close wallet" menu is not working but wallet is actually removed which can be confirmed by restarting qt this PR/previous behaviour: wallet is actually gone from ui asap ## Breaking Changes n/a ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: kwvg: utACK 826221b Tree-SHA512: ac50b9f3b7ceb0884a7e51aaf20f66753376569e42327331be8d6635d9b20d56034f6b2655406196e4882b1c4c3dcdbad6311b7b92786a7e51241c6255fdb785
2 parents 370b85b + 826221b commit c6be968

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/qt/walletcontroller.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ std::map<std::string, bool> WalletController::listWalletDir() const
7878
return wallets;
7979
}
8080

81-
void WalletController::removeWallet(WalletModel* wallet_model)
82-
{
83-
// Once the wallet is successfully removed from the node, the model will emit the 'WalletModel::unload' signal.
84-
// This signal is already connected and will complete the removal of the view from the GUI.
85-
// Look at 'WalletController::getOrCreateWallet' for the signal connection.
86-
wallet_model->wallet().remove();
87-
}
88-
8981
void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
9082
{
9183
QMessageBox box(parent);
@@ -96,7 +88,10 @@ void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
9688
box.setDefaultButton(QMessageBox::Yes);
9789
if (box.exec() != QMessageBox::Yes) return;
9890

99-
removeWallet(wallet_model);
91+
// First remove wallet from node.
92+
wallet_model->wallet().remove();
93+
// Now release the model.
94+
removeAndDeleteWallet(wallet_model);
10095
}
10196

10297
void WalletController::closeAllWallets(QWidget* parent)
@@ -109,8 +104,11 @@ void WalletController::closeAllWallets(QWidget* parent)
109104

110105
QMutexLocker locker(&m_mutex);
111106
for (WalletModel* wallet_model : m_wallets) {
112-
removeWallet(wallet_model);
107+
wallet_model->wallet().remove();
108+
Q_EMIT walletRemoved(wallet_model);
109+
delete wallet_model;
113110
}
111+
m_wallets.clear();
114112
}
115113

116114
WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet)

src/qt/walletcontroller.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ class WalletController : public QObject
7979
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
8080

8181
friend class WalletControllerActivity;
82-
83-
//! Starts the wallet closure procedure
84-
void removeWallet(WalletModel* wallet_model);
8582
};
8683

8784
class WalletControllerActivity : public QObject

0 commit comments

Comments
 (0)