-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ditch wallet model juggling #417
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,21 +125,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 /* 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. | ||
QMetaObject::invokeMethod(this, [wallet_model, this] { | ||
wallet_model->setParent(this); | ||
WalletModel* wallet_model; | ||
// Instantiate model in GUI main thread. | ||
QMetaObject::invokeMethod(this, [&] { | ||
wallet_model = new WalletModel(std::move(wallet), m_client_model, m_platform_style, this); | ||
}, GUIUtil::blockingGUIThreadConnection()); | ||
|
||
wallet_model->preload(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a follow-up, some preload will be replaced by lazy loading. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In commit "qt: Move wallet preloading out of model constructors" (e2ffc98) I think it would be good to switch the order of the two commits so the other commit doesn't cause a performance regression, and so wallet preloading doesn't move from the outside thread to the GUI thread than back to the outside thread again within the PR. Additionally might suggest renaming Also would add a rationale to the commit description like:
|
||
|
||
m_wallets.push_back(wallet_model); | ||
|
||
// WalletModel::startPollBalance needs to be called in a thread managed by | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "qt: Ditch wallet model juggling" (f3e7047)
It seems unfortunate that this commit is deleting previous comment which explained what this code was trying to do, replacing it with a much shorter comment that doesn't provide much explanation.
It would be good to combine two comments with something like:
I also think commit message is unclear about what behavior is changing. Initially I didn't realize that constructing the WalletModel was so expensive and actually loaded transactions, so this at first appeared to be a no-op change that was replacing setParent and moveToThread calls with a constructor call. Would suggest adding an explanation like the following to the commit message:
Or, as an alternative, if you switch the order of the two commits, you could drop "This commit however can cause GUI freezes..." part and everything after.