Skip to content

Commit cadb9d3

Browse files
committed
Merge #18036: gui: Break trivial circular dependencies
3aee10b gui: Drop ShutdownWindow dependency to BitcoinGUI (João Barbosa) 61eb058 gui: Drop BanTableModel dependency to ClientModel (João Barbosa) Pull request description: `ShutdownWindow::showShutdownWindow` just needs a widget to center the shutdown window and to borrow its title. ACKs for top commit: hebasto: ACK 3aee10b, since previous review only suggested change `QWidget` --> `QMainWindow` jonasschnelli: utACK 3aee10b Tree-SHA512: e15cb6ee274730bd071d3d97b540c5059e5c655248d69a37c3fd00f2aacc6cfcb36b9a65755718027e15482ec8e5e85534c1dc13d0ddb4e0680df03fbf6571f2
2 parents d104aa0 + 3aee10b commit cadb9d3

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

src/qt/bantablemodel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
#include <interfaces/node.h>
88
#include <net_types.h> // For banmap_t
9-
#include <qt/clientmodel.h>
109

1110
#include <utility>
1211

13-
#include <QDebug>
12+
#include <QDateTime>
1413
#include <QList>
14+
#include <QModelIndex>
15+
#include <QVariant>
1516

1617
bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan& right) const
1718
{
@@ -78,10 +79,9 @@ class BanTablePriv
7879
}
7980
};
8081

81-
BanTableModel::BanTableModel(interfaces::Node& node, ClientModel *parent) :
82+
BanTableModel::BanTableModel(interfaces::Node& node, QObject* parent) :
8283
QAbstractTableModel(parent),
83-
m_node(node),
84-
clientModel(parent)
84+
m_node(node)
8585
{
8686
columns << tr("IP/Netmask") << tr("Banned Until");
8787
priv.reset(new BanTablePriv());

src/qt/bantablemodel.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <QAbstractTableModel>
1313
#include <QStringList>
1414

15-
class ClientModel;
1615
class BanTablePriv;
1716

1817
namespace interfaces {
@@ -45,7 +44,7 @@ class BanTableModel : public QAbstractTableModel
4544
Q_OBJECT
4645

4746
public:
48-
explicit BanTableModel(interfaces::Node& node, ClientModel *parent = nullptr);
47+
explicit BanTableModel(interfaces::Node& node, QObject* parent);
4948
~BanTableModel();
5049
void startAutoRefresh();
5150
void stopAutoRefresh();
@@ -72,7 +71,6 @@ public Q_SLOTS:
7271

7372
private:
7473
interfaces::Node& m_node;
75-
ClientModel *clientModel;
7674
QStringList columns;
7775
std::unique_ptr<BanTablePriv> priv;
7876
};

src/qt/utilitydialog.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
#include <qt/forms/ui_helpmessagedialog.h>
1212

13-
#include <qt/bitcoingui.h>
14-
1513
#include <clientversion.h>
1614
#include <init.h>
1715
#include <util/system.h>
@@ -21,9 +19,10 @@
2119

2220
#include <QCloseEvent>
2321
#include <QLabel>
22+
#include <QMainWindow>
2423
#include <QRegExp>
25-
#include <QTextTable>
2624
#include <QTextCursor>
25+
#include <QTextTable>
2726
#include <QVBoxLayout>
2827

2928
/** "Help message" or "About" dialog box */
@@ -144,10 +143,9 @@ ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
144143
setLayout(layout);
145144
}
146145

147-
QWidget *ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
146+
QWidget* ShutdownWindow::showShutdownWindow(QMainWindow* window)
148147
{
149-
if (!window)
150-
return nullptr;
148+
assert(window != nullptr);
151149

152150
// Show a simple window indicating shutdown status
153151
QWidget *shutdownWindow = new ShutdownWindow();

src/qt/utilitydialog.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#define BITCOIN_QT_UTILITYDIALOG_H
77

88
#include <QDialog>
9-
#include <QObject>
9+
#include <QWidget>
1010

11-
class BitcoinGUI;
11+
QT_BEGIN_NAMESPACE
12+
class QMainWindow;
13+
QT_END_NAMESPACE
1214

1315
namespace interfaces {
1416
class Node;
@@ -46,7 +48,7 @@ class ShutdownWindow : public QWidget
4648

4749
public:
4850
explicit ShutdownWindow(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Widget);
49-
static QWidget *showShutdownWindow(BitcoinGUI *window);
51+
static QWidget* showShutdownWindow(QMainWindow* window);
5052

5153
protected:
5254
void closeEvent(QCloseEvent *event);

test/lint/lint-circular-dependencies.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
1313
"index/txindex -> validation -> index/txindex"
1414
"policy/fees -> txmempool -> policy/fees"
1515
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
16-
"qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel"
17-
"qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui"
1816
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
1917
"qt/bitcoingui -> qt/walletview -> qt/bitcoingui"
2018
"qt/clientmodel -> qt/peertablemodel -> qt/clientmodel"

0 commit comments

Comments
 (0)