Skip to content

Commit 41b0baf

Browse files
committed
gui: Handle WalletModel::unload asynchronous
This change prevents deleting a WalletModel instance while it's being used.
1 parent ab31b9d commit 41b0baf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/qt/walletcontroller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
116116
const bool called = QMetaObject::invokeMethod(wallet_model, "startPollBalance");
117117
assert(called);
118118

119-
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
119+
connect(wallet_model, &WalletModel::unload, this, [this, wallet_model] {
120120
// Defer removeAndDeleteWallet when no modal widget is active.
121121
// TODO: remove this workaround by removing usage of QDiallog::exec.
122122
if (QApplication::activeModalWidget()) {
@@ -128,7 +128,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
128128
} else {
129129
removeAndDeleteWallet(wallet_model);
130130
}
131-
});
131+
}, Qt::QueuedConnection);
132132

133133
// Re-emit coinsSent signal from wallet model.
134134
connect(wallet_model, &WalletModel::coinsSent, this, &WalletController::coinsSent);

0 commit comments

Comments
 (0)