mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
gui: Handle WalletModel::unload asynchronous
This change prevents deleting a WalletModel instance while it's being used.
This commit is contained in:
parent
ab31b9d6fe
commit
41b0baf43c
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user