Skip to content

Commit 5fcfee6

Browse files
committed
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.
1 parent 5659e73 commit 5fcfee6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/qt/walletcontroller.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wal
131131
WalletModel* wallet_model = new WalletModel(std::move(wallet), m_client_model, m_platform_style, nullptr);
132132
// Handler callback runs in a different thread so fix wallet model thread affinity.
133133
wallet_model->moveToThread(thread());
134-
wallet_model->setParent(this);
134+
// setParent(parent) must be called in the thread which created the parent object. More details in #18948.
135+
GUIUtil::ObjectInvoke(this, [wallet_model, this] {
136+
wallet_model->setParent(this);
137+
}, GUIUtil::blockingGUIThreadConnection());
138+
135139
m_wallets.push_back(wallet_model);
136140

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

0 commit comments

Comments
 (0)