mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
gui: Handle WalletModel::unload asynchronous
This change prevents deleting a WalletModel instance while it's being used.
This commit is contained in:
@@ -116,7 +116,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
|
|||||||
const bool called = QMetaObject::invokeMethod(wallet_model, "startPollBalance");
|
const bool called = QMetaObject::invokeMethod(wallet_model, "startPollBalance");
|
||||||
assert(called);
|
assert(called);
|
||||||
|
|
||||||
connect(wallet_model, &WalletModel::unload, [this, wallet_model] {
|
connect(wallet_model, &WalletModel::unload, this, [this, wallet_model] {
|
||||||
// Defer removeAndDeleteWallet when no modal widget is active.
|
// Defer removeAndDeleteWallet when no modal widget is active.
|
||||||
// TODO: remove this workaround by removing usage of QDiallog::exec.
|
// TODO: remove this workaround by removing usage of QDiallog::exec.
|
||||||
if (QApplication::activeModalWidget()) {
|
if (QApplication::activeModalWidget()) {
|
||||||
@@ -128,7 +128,7 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
|
|||||||
} else {
|
} else {
|
||||||
removeAndDeleteWallet(wallet_model);
|
removeAndDeleteWallet(wallet_model);
|
||||||
}
|
}
|
||||||
});
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
// Re-emit coinsSent signal from wallet model.
|
// Re-emit coinsSent signal from wallet model.
|
||||||
connect(wallet_model, &WalletModel::coinsSent, this, &WalletController::coinsSent);
|
connect(wallet_model, &WalletModel::coinsSent, this, &WalletController::coinsSent);
|
||||||
|
|||||||
Reference in New Issue
Block a user