-
Notifications
You must be signed in to change notification settings - Fork 283
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
refactor: Pass WalletModel object to the WalletView constructor #398
Conversation
Concept ACK |
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.
Wrong tab, sorry, deletec ack.
…tatuses simpler b8aa84b qt, refactor: Replace `if` check with `assert` (Hennadii Stepanov) fcdc8b0 qt, refactor: Drop redundant signalling in WalletView::setWalletModel (Hennadii Stepanov) 37dcf16 qt, refactor: Emit WalletView::encryptionStatusChanged signal directly (Hennadii Stepanov) 7d0d4c0 qt: Add WalletFrame::currentWalletSet signal (Hennadii Stepanov) Pull request description: This PR makes signal-slot paths to reach `setHDStatus` and `setEncryptionStatus` functions shorter and easier to reason about them. Required to simplify #398 (see #398 (comment)). --- **Note for reviewers.** Please verify that "Encrypt Wallet..." menu item, and the following icons  and updated properly in each and every possible scenario. ACKs for top commit: jarolrod: tACK b8aa84b Talkless: Code review ACK b8aa84b. Did build on Debian Sid with Qt 5.15.2 but no actual testing performed. ryanofsky: Code review ACK b8aa84b. Only change since last review was rebase Tree-SHA512: 275737cdba02baff71049df41bc24089e916f96326dd2dea26ec607c7949cb3aae368eeabbe3ad5a0a27651503a1d65536873726de854c5f6af259bcc29727e7
An instance of the WalletView class without walletModel data member being set is invalid. So, it is better to set it in the constructor.
The walletModel member is set in the WalletView constructor now.
Code review ACK 92ddc02 |
No need to pass an instance of the WalletModel class to this method. Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
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.
Code review ACK d319c4d
These changes seem to simplify the code a great bit. Thanks for this amazing work!
I have compiled some notes regarding the changes made in each of the commits in this PR. However, @hebasto has very clearly mentioned the details in the commit message of each commit. I still think my notes might be of some help to fellow reviewers.
NOTES:
- qt, refactor: Pass WalletModel object to WalletView constructor
- The process of creating
walletmodel
has been moved under the constructor of theWalletView
class. - The redundant function of creating a
walletmodel
has been removed. walletview.h
file has been appropriately modified to account for all the changes made in thewalletview.cpp
file.
- The process of creating
- qt, refactor: Drop redundant checks of walletModel
- As the name suggests, all the redundant checks of
walletModel
in thewalletview.cpp
file have been removed, as thewalletmodel
is now constructed during the construction of thewalletview
object itself.
- As the name suggests, all the redundant checks of
- qt, refactor: Declare getWalletModel with const and noexcept qualifiers
- This is done to ensure that the function is not changing a member variable’s value. And the given function will not throw an exception (since the
walletmodel
is generated with the constructor itself).
- This is done to ensure that the function is not changing a member variable’s value. And the given function will not throw an exception (since the
- qt, refactor: Replace WalletFrame::addWallet with WalletFrame::addView
- Modified the
addWallet
function such that it now doesn’t need to takewalletmodel
as an argument. And also removed the need to check for the existence of awalletmodel
inside this function.
- Modified the
If some of my observation is erroneous or lacking thorough observation, please do inform me.
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.
Code review ACK d319c4d.
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 d319c4d
I did light testing with different wallets and switching between them. I also ran the qt tests locally. Performed identical testing steps on macOS and on Ubuntu.
This is a nice simplification of the WalletModel/WalletView logic. It ties up nicely at the end with the last commit where we now only need to pass the WalletView object; not both a WalletModel and WalletView object.
@ShaMan239 your notes on the PR are excellent and I looked at them before beginning my review. Thanks for posting them!
Updated Namecoin UI for bitcoin-core/gui#398.
An instance of the
WalletView
class without thewalletModel
data member being set is invalid. So, it is better to set it in the constructor.Establishing one more
WalletView
class's invariant in constructor:walletModel
in member functionsWalletView
class easierPossible follow ups could extend this approach to other classes, e.g.,
OverviewPage
,TransactionView
,ReceiveCoinsDialog
,SendCoinsDialog
,AddressBookPage
.