This PR:
- gets rid of
qt/bitcoingui
->qt/walletframe
->qt/bitcoingui
circular 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?
nullptr
)?
Come on, it’s being set as the central widget in the next line.. a minimal change to remove the circular dependency is
0--- a/src/qt/walletframe.cpp
1+++ b/src/qt/walletframe.cpp
2@@ -5,7 +5,6 @@
3 #include <qt/walletframe.h>
4 #include <qt/walletmodel.h>
5
6-#include <qt/bitcoingui.h>
7 #include <qt/walletview.h>
8
9 #include <cassert>
10@@ -14,7 +13,7 @@
11 #include <QLabel>
12
13 WalletFrame::WalletFrame(const PlatformStyle *_platformStyle, BitcoinGUI *_gui) :
14- QFrame(_gui),
15+ QFrame(nullptr),
16 gui(_gui),
17 platformStyle(_platformStyle)
18 {
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
.cpp
and.h
file should#include
every 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.
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.
clang-format-diff.py
to his own commits?
clang-format-diff.py
changes are fine.
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
Nice to see the list of circular dependencies shrink towards length zero :)
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);
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.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
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.