Skip to content

Commit

Permalink
qt: Call setParent() in the parent's context
Browse files Browse the repository at this point in the history
setParent(parent) calls sendEvent(parent, QChildEvent) that implies
running in the thread which created the parent object.
  • Loading branch information
hebasto committed Nov 25, 2020
1 parent 5659e73 commit 5fcfee6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// Handler callback runs in a different thread so fix wallet model thread affinity.
wallet_model->moveToThread(thread());
wallet_model->setParent(this);
// 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);
}, GUIUtil::blockingGUIThreadConnection());

m_wallets.push_back(wallet_model);

// WalletModel::startPollBalance needs to be called in a thread managed by
Expand Down

0 comments on commit 5fcfee6

Please sign in to comment.