From 3a03f075606b19e411b8bd19870242e0e0b58fcb Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Tue, 29 Jul 2025 09:12:46 +0100 Subject: [PATCH] qt: Avoid header circular dependency --- src/qt/freespacechecker.cpp | 6 ------ src/qt/freespacechecker.h | 12 ++++++++---- src/qt/intro.h | 8 ++++---- test/lint/lint-circular-dependencies.py | 1 - 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/qt/freespacechecker.cpp b/src/qt/freespacechecker.cpp index e0f6fff3183..53cb6a71510 100644 --- a/src/qt/freespacechecker.cpp +++ b/src/qt/freespacechecker.cpp @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -13,11 +12,6 @@ #include -FreespaceChecker::FreespaceChecker(Intro *_intro) -{ - this->intro = _intro; -} - void FreespaceChecker::check() { QString dataDirStr = intro->getPathToCheck(); diff --git a/src/qt/freespacechecker.h b/src/qt/freespacechecker.h index ebd36bde974..e1746a8f457 100644 --- a/src/qt/freespacechecker.h +++ b/src/qt/freespacechecker.h @@ -9,8 +9,6 @@ #include #include -class Intro; - /* Check free space asynchronously to prevent hanging the UI thread. Up to one request to check a path is in flight to this thread; when the check() @@ -26,7 +24,13 @@ class FreespaceChecker : public QObject Q_OBJECT public: - explicit FreespaceChecker(Intro *intro); + class PathQuery + { + public: + virtual QString getPathToCheck() = 0; + }; + + explicit FreespaceChecker(PathQuery* intro) : intro{intro} {} enum Status { ST_OK, @@ -40,7 +44,7 @@ Q_SIGNALS: void reply(int status, const QString &message, quint64 available); private: - Intro *intro; + PathQuery* intro; }; #endif // BITCOIN_QT_FREESPACECHECKER_H diff --git a/src/qt/intro.h b/src/qt/intro.h index 1fac5c39531..db6c1d50b23 100644 --- a/src/qt/intro.h +++ b/src/qt/intro.h @@ -5,14 +5,14 @@ #ifndef BITCOIN_QT_INTRO_H #define BITCOIN_QT_INTRO_H +#include + #include #include #include static const bool DEFAULT_CHOOSE_DATADIR = false; -class FreespaceChecker; - namespace interfaces { class Node; } @@ -25,7 +25,7 @@ namespace Ui { Allows the user to choose a data directory, in which the wallet and block chain will be stored. */ -class Intro : public QDialog +class Intro : public QDialog, public FreespaceChecker::PathQuery { Q_OBJECT @@ -78,7 +78,7 @@ private: void startThread(); void checkPath(const QString &dataDir); - QString getPathToCheck(); + QString getPathToCheck() override; void UpdatePruneLabels(bool prune_checked); void UpdateFreeSpaceLabel(); diff --git a/test/lint/lint-circular-dependencies.py b/test/lint/lint-circular-dependencies.py index 2ec79724d10..9554e560650 100755 --- a/test/lint/lint-circular-dependencies.py +++ b/test/lint/lint-circular-dependencies.py @@ -16,7 +16,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES = ( "node/blockstorage -> validation -> node/blockstorage", "node/utxo_snapshot -> validation -> node/utxo_snapshot", "qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel", - "qt/freespacechecker -> qt/intro -> qt/freespacechecker", "qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel", "qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog", "qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",