-
Notifications
You must be signed in to change notification settings - Fork 273
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
Switch to the selected wallet after loading #665
Conversation
Maybe amend a PR title/commit message to mention "switch to the selected wallet after loading"? |
@@ -410,7 +410,7 @@ void BitcoinGUI::createActions() | |||
|
|||
connect(action, &QAction::triggered, [this, path] { | |||
auto activity = new OpenWalletActivity(m_wallet_controller, this); | |||
connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet); | |||
connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection); |
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.
Why this solution works?
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.
There's a good explanation here: #471 (review) as this is the same case found in Restore Wallet.
As the default value for this parameter is Qt::AutoConnection
, it appears to be using Qt::DirectConnection
, in which the slot is invoked immediately.
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.
Feels like a race that would be better being explicitly handled in the correct order?
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.
I think Qt::DirectConnection
guarantees the correct order in this case, as BitcoinGUI::setCurrentWallet
will only run after control returns to the event loop of the receiver's thread.
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.
ACK b8b59ff
Can confirm that this fixes the issue. It appears safe to explicitly specify what kind of ConnectionType
we want, there isn't an issue with the parameters given to the meta system and queuing this. We probably still want to continue to flesh this out and determine if we can refactor to remove explicitly specifying the ConnectionType
Tested ACK on ubuntu 20.04. Loading a wallet now sets it on the "Wallet:" combobox at the top right hand corner. So far I couldn't find if there's an alternative to avoid specifying the ConnectionType on the params. I see the different types will depend on whether the sender and receiver belong to the same thread or not. |
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.
Concept ACK. It'd be nice if Console switches too; wouldn't be the first time I import descriptors into the wrong wallet :-) |
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.
ACK b8b59ff, tested on Ubuntu 22.04.
Feels like a race that would be better being explicitly handled in the correct order?
Yes, a PR with a better solution is welcome.
…ly opened/restored/created 99c0eb9 Fix RPCConsole wallet selection (John Moffett) Pull request description: If a user opens multiple wallets in the GUI from the menu bar, the last one opened is the active one in the main window. However, For the RPC Console window, the _first_ one opened is active. This can be confusing, as wallet RPC commands may be sent to a wallet the user didn't intend. This PR makes the RPC Console switch to the wallet just opened / restored / created from the menu bar, which is how the main GUI now works. Similar to #665 and specifically requested [in a comment](#665 (comment)). ACKs for top commit: luke-jr: utACK 99c0eb9 hebasto: ACK 99c0eb9, tested on Ubuntu 23.04. Tree-SHA512: d5e5acdaa114130ad4d27fd3f25393bc8d02d92b5001cd39352601d04283cdad3bd62c4da6d369c69764e3b188e9cd3e83152c00b09bd42966082ad09037c328
Currently, the user loads a wallet and the screen does not switch to the selected wallet after loading (File -> Open Wallet -> wallet name).
This PR changes that by making the
OpenWalletActivity::opened
signal connection aQt::QueuedConnection
type.