aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletcontroller.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-05-11 17:12:59 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-11-25 16:12:33 +0200
commit8963b2c71f120b2746396c4987392f0105c8dd60 (patch)
treefc68e4e836f895ad54f477e30f7111e70fe08096 /src/qt/walletcontroller.cpp
parent5fcfee68af47d4a891ae9c9964d73886f0f01d7d (diff)
qt: Improve comments in WalletController::getOrCreateWallet()
Diffstat (limited to 'src/qt/walletcontroller.cpp')
-rw-r--r--src/qt/walletcontroller.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index a59f33b785..83f3cccbff 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -128,8 +128,14 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
}
// Instantiate model and register it.
- WalletModel* wallet_model = new WalletModel(std::move(wallet), m_client_model, m_platform_style, nullptr);
- // Handler callback runs in a different thread so fix wallet model thread affinity.
+ WalletModel* wallet_model = new WalletModel(std::move(wallet), m_client_model, m_platform_style,
+ nullptr /* required for the following moveToThread() call */);
+
+ // Move WalletModel object to the thread that created the WalletController
+ // object (GUI main thread), instead of the current thread, which could be
+ // an outside wallet thread or RPC thread sending a LoadWallet notification.
+ // This ensures queued signals sent to the WalletModel object will be
+ // handled on the GUI event loop.
wallet_model->moveToThread(thread());
// setParent(parent) must be called in the thread which created the parent object. More details in #18948.
GUIUtil::ObjectInvoke(this, [wallet_model, this] {
@@ -161,7 +167,6 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
// Re-emit coinsSent signal from wallet model.
connect(wallet_model, &WalletModel::coinsSent, this, &WalletController::coinsSent);
- // Notify walletAdded signal on the GUI thread.
Q_EMIT walletAdded(wallet_model);
return wallet_model;