-
Notifications
You must be signed in to change notification settings - Fork 37.7k
gui: Add WalletController #15101
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
gui: Add WalletController #15101
Conversation
d7d57d7
to
f9b606e
Compare
Split in multiple commits for easier review. |
4bb0233
to
23aae3d
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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.
tACK 23aae3d on macOS 10.14.2 with QT 5.11.2, also with --disable-wallet
, with and without BIP70.
I'm not sure how to test unloading of wallets; it tends to return "unable to".
Without wallet there's a warning:
qt/rpcconsole.cpp:908:22: warning: unused variable 'wallet_model' [-Wunused-variable]
WalletModel* wallet_model{nullptr};
#14784 is merged now, so you can edit the top comment
Maybe move qRegisterMetaType
into the controller so you can remove the walletmodel.h
dependency from qt/bitcoin.cpp
?
45ecc25
to
5e4cb35
Compare
re-tACK 5e4cb35, it seems to fix the crashes we discussed on IRC. I noticed you removed the |
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.
Looks good. A few comments and questions inline.
I agree with Sjors that m_history
is unnecessary and should be dropped from this PR.
5e4cb35
to
744f0e3
Compare
744f0e3
to
20f11da
Compare
Rebased with #15149 to avoid conflicts. |
20f11da
to
3c50d90
Compare
e79abc7
to
89fa546
Compare
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.
Lightly tested ACK 89fa546e8211aa47c96e20ba2a80507acd125539.
One question inline.
89fa546
to
a9a3069
Compare
@jnewbery done. |
Rebased. |
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.
tACK 1316f57
By the way, I'm seeing the following warning when compiling with --disable-wallet
, probably from a previous commit:
qt/rpcconsole.cpp:909:22: warning: unused variable 'wallet_model' [-Wunused-variable]
WalletModel* wallet_model{nullptr};
^
@@ -599,13 +615,19 @@ void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model) | |||
{ | |||
if (!walletFrame) return; | |||
walletFrame->setCurrentWallet(wallet_model); | |||
for (int index = 0; index < m_wallet_selector->count(); ++index) { |
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.
Nit: ->itemData()
can give you an iterator, which you can use for the loop, to prevent out of bounds accidents: http://doc.qt.io/qt-5/qvariant.html
Maybe it also has a helper to just find the index you need directly.
/** | ||
* WalletController | ||
*/ | ||
class WalletController : public QObject |
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.
Nit: WalletsController?
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.
heh 😛avoid plural?
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.
Plural makes it clear that this controls multiple wallets, rather than one controller per 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.
I prefer to interpret it as the "gui controller of the wallet related things". Let's see what others say and I'll happily rename.
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 either is fine.
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.
Tech language prefers a singular form; e.g., "window manager", "file manager" etc.
Tested ACK 1316f5706891bb94428078e874e761931ff0e087 Only difference is rebasing on master and removing the unused EDIT: pasted incorrect commit id. Now fixed |
1316f57
to
1b82938
Compare
1b82938
to
0dd9bde
Compare
Refactored a bit to simplify follow ups. |
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.
re-tACK 0dd9bde
@@ -376,7 +376,7 @@ bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureStri | |||
static void NotifyUnload(WalletModel* walletModel) | |||
{ | |||
qDebug() << "NotifyUnload"; | |||
QMetaObject::invokeMethod(walletModel, "unload", Qt::QueuedConnection); | |||
QMetaObject::invokeMethod(walletModel, "unload"); |
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.
Can you elaborate on why this is safe? I'm still wrapping my head around how QT deals with threads: http://doc.qt.io/qt-5/qobject.html#thread-affinity
Is it similar to iOs where the UI can only be touched from the main thread, but notifications tend to arrive on different threads, leading to nasty crashes if you don't pay attention? How do you know which thread NotifyUnload
is called on?
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 https://woboq.com/blog/how-qt-signals-slots-work.html is a good read.
Each QObject
belongs to one thread which must have one event loop spinning. With the default AutoConnection
Qt ensures that the slot is executed in the receiver thread, so it either calls the slot directly (if the emit happens in the same thread) or enqueues an event (with all signal arguments) in the receiver event loop.
utACK 0dd9bde |
Tested ACK 0dd9bde |
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of #13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
0dd9bde gui: Refactor to use WalletController (João Barbosa) 8fa271f gui: Add WalletController (João Barbosa) cefb399 gui: Use AutoConnection for WalletModel::unload signal (João Barbosa) Pull request description: This PR is a subset of the work done in the context of bitcoin#13100. This change consists in extracting from the application class the code that manages the wallet models. The role of the `WalletController` instance is to coordinate wallet operations and the window. Tree-SHA512: 6a824054376730eb7d16c643dd2003f5f60778e8ad3af707b82bc12c48438db179ca4446316b28fb17b206f4b9aba8998419aab8c5dd1f7c32467015732b5094
This PR is a subset of the work done in the context of #13100. This change consists in extracting from the application class the code that manages the wallet models.
The role of the
WalletController
instance is to coordinate wallet operations and the window.