This PR:
- gets rid of
qt/bitcoingui->qt/walletframe->qt/bitcoinguicircular dependency - ~is based on top of #17499 (as a prerequisite)~ (merged)
97 | @@ -98,7 +98,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty 98 | if(enableWallet) 99 | { 100 | /** Create wallet frame and make it the central widget */ 101 | - walletFrame = new WalletFrame(_platformStyle, this); 102 | + walletFrame = new WalletFrame(_platformStyle, this, this);
1f913ac9a00b982c997e70603ba62eebbe4c9d03
Why set parent if setCentralWidget changes it?
If a widget is not intended to be a window why create it as a window (parent == nullptr)?
Come on, it's being set as the central widget in the next line.. a minimal change to remove the circular dependency is
--- a/src/qt/walletframe.cpp
+++ b/src/qt/walletframe.cpp
@@ -5,7 +5,6 @@
#include <qt/walletframe.h>
#include <qt/walletmodel.h>
-#include <qt/bitcoingui.h>
#include <qt/walletview.h>
#include <cassert>
@@ -14,7 +13,7 @@
#include <QLabel>
WalletFrame::WalletFrame(const PlatformStyle *_platformStyle, BitcoinGUI *_gui) :
- QFrame(_gui),
+ QFrame(nullptr),
gui(_gui),
platformStyle(_platformStyle)
{
16 | @@ -17,6 +17,7 @@ class WalletView; 17 | 18 | QT_BEGIN_NAMESPACE 19 | class QStackedWidget; 20 | +class QWidget;
1f913ac9a00b982c997e70603ba62eebbe4c9d03
Why? QFrame extends it so it's available
Developer Notes - Source code organization:
- Every
.cppand.hfile should#includeevery header file it directly uses classes, functions or other definitions from, even if those headers are already included indirectly through other headers.
- Rationale: Excluding headers because they are already indirectly included results in compilation failures when those indirect dependencies change. Furthermore, it obscures what the real code dependencies are.
Doest that apply for forward declarations?
I think it's okay to leave it, though FWIW forward-declaring QWidget should never be necessary.
It is impossible to derive from QFrame if the full definition of QWidget (which is its ancestor) isn't available.
18 | - QFrame(_gui), 19 | - gui(_gui), 20 | - platformStyle(_platformStyle) 21 | +WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, BitcoinGUI* _gui, QWidget* parent) 22 | + : QFrame(parent), 23 | + gui(_gui),
1f913ac9a00b982c997e70603ba62eebbe4c9d03
nack style change.
Shouldn't a contributor consistently apply clang-format-diff.py to his own commits?
I personally don't if it makes the diff larger than necessary.
Probably irrelevant... I think clang-format-diff.py changes are fine.
I think in general it's important to limit changes to only the code that is touched, so that it is easy to see the real changes. But in this case, bah, an argument is added and some spaces are added to the other lines it's fine with me. I don't think it interferes with review enough to complain.
See comment above https://github.com/bitcoin/bitcoin/pull/17500/files#r347153585
2 | @@ -3,20 +3,19 @@ 3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 | 5 | #include <qt/walletframe.h> 6 | -#include <qt/walletmodel.h> 7 | 8 | -#include <qt/bitcoingui.h> 9 | +#include <qt/walletmodel.h>
1f913ac9a00b982c997e70603ba62eebbe4c9d03
Looks like this is the only change needed?
Concept ACK.
Concept ACK
Nice to see the list of circular dependencies shrink towards length zero :)
Concept ACK
31 | @@ -31,7 +32,7 @@ class WalletFrame : public QFrame 32 | Q_OBJECT 33 | 34 | public: 35 | - explicit WalletFrame(const PlatformStyle *platformStyle, BitcoinGUI *_gui = nullptr); 36 | + WalletFrame(const PlatformStyle* platformStyle, BitcoinGUI* _gui, QWidget* parent);
Please keep the explicit here. Even though this can likely never happen with three arguments without a default value, it's better to specify it unless you want the object to ever be implicitly constructed.
Agree.
TIL: from C++11 a converting constructor can accept any number of parameters, not a single parameter.
Please keep the explicit here.
Done.
If a widget is not intended to be a window why create it as a window (parent ==
nullptr)?
Good point, from doc https://doc.qt.io/qt-5/qwidget.html#QWidget
From IRC:
promag hebasto: afaik instancing a widget with null parent doesn't make it a window - at least until you show() it wumpus please check that very carefully wumpus if you're not sure, err on the safe side
Qt does exactly what @hebasto is doing here so approach ACK. Thanks @laanwj.
Please rebase.
Please rebase.
Rebased.
Core review ACK 2ee0b8aebce0d2a889199bde40ec6ba590c42507.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Conceptually there's still a circular reference which is unnecessary. Instead of passing thru BitcoinGUI I think WalletFrame should re-emit wallet view signals.