qt: Call setParent() in the parent's context

setParent(parent) calls sendEvent(parent, QChildEvent) that implies
running in the thread which created the parent object.
This commit is contained in:
Hennadii Stepanov 2020-08-14 20:53:35 +03:00
parent 5659e73493
commit 5fcfee68af
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

View File

@ -131,7 +131,11 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
WalletModel* wallet_model = new WalletModel(std::move(wallet), m_client_model, m_platform_style, nullptr); 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. // Handler callback runs in a different thread so fix wallet model thread affinity.
wallet_model->moveToThread(thread()); 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] {
wallet_model->setParent(this); wallet_model->setParent(this);
}, GUIUtil::blockingGUIThreadConnection());
m_wallets.push_back(wallet_model); m_wallets.push_back(wallet_model);
// WalletModel::startPollBalance needs to be called in a thread managed by // WalletModel::startPollBalance needs to be called in a thread managed by