Move FreespaceChecker class into its own module #881

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:250726-intro changing 5 files +117 −90
  1. hebasto commented at 10:13 am on July 26, 2025: member

    For some reason, the MOC compiler in older versions of Qt 6 fails to parse qt/intro.cpp, as noted in this comment.

    This PR proposes a move-only refactoring to simplify the source structure by eliminating the need for the inline #include <qt/intro.moc>, thereby effectively working around the issue.

    Required for https://github.com/bitcoin/bitcoin/pull/32998.

  2. hebasto added the label Refactoring on Jul 26, 2025
  3. DrahtBot commented at 10:13 am on July 26, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK ajtowns

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. DrahtBot added the label CI failed on Jul 26, 2025
  5. DrahtBot commented at 2:07 pm on July 26, 2025: contributor

    🚧 At least one of the CI tasks failed. Task lint: https://github.com/bitcoin-core/gui/runs/46777090693 LLM reason (✨ experimental): The CI failure is caused by multiple linting errors including a circular dependency, missing include guards, and other linting checks.

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  6. hebasto force-pushed on Jul 26, 2025
  7. hebasto force-pushed on Jul 26, 2025
  8. hebasto force-pushed on Jul 26, 2025
  9. DrahtBot removed the label CI failed on Jul 26, 2025
  10. ajtowns commented at 5:17 am on July 29, 2025: contributor

    ACK dd392a64bb0608847f771f8b1f09c2fcae146923

    Shouldn’t the copyright dates in these files be updated? git blame has some lines from 2022 in intro.h and 2024/25 in intro.cpp.

    You could avoid the circularity with something like:

      0diff --git a/src/qt/freespacechecker.h b/src/qt/freespacechecker.h
      1index d3a61a11571..214324be7c8 100644
      2--- a/src/qt/freespacechecker.h
      3+++ b/src/qt/freespacechecker.h
      4@@ -9,8 +9,6 @@
      5 #include <QString>
      6 #include <QtGlobal>
      7
      8-class Intro;
      9-
     10 /* Check free space asynchronously to prevent hanging the UI thread.
     11
     12    Up to one request to check a path is in flight to this thread; when the check()
     13@@ -26,7 +24,12 @@ class FreespaceChecker : public QObject
     14     Q_OBJECT
     15
     16 public:
     17-    explicit FreespaceChecker(Intro *intro);
     18+    class PathQuery {
     19+    public:
     20+        virtual QString getPathToCheck() = 0;
     21+    };
     22+
     23+    explicit FreespaceChecker(PathQuery* intro) : intro{intro} { }
     24
     25     enum Status {
     26         ST_OK,
     27@@ -40,7 +43,7 @@ Q_SIGNALS:
     28     void reply(int status, const QString &message, quint64 available);
     29
     30 private:
     31-    Intro *intro;
     32+    PathQuery* intro;
     33 };
     34
     35 #endif // BITCOIN_QT_FREESPACECHECKER_H
     36diff --git a/src/qt/freespacechecker.cpp b/src/qt/freespacechecker.cpp
     37index 28c55baf7d0..c259facb782 100644
     38--- a/src/qt/freespacechecker.cpp
     39+++ b/src/qt/freespacechecker.cpp
     40@@ -5,7 +5,6 @@
     41 #include <qt/freespacechecker.h>
     42
     43 #include <qt/guiutil.h>
     44-#include <qt/intro.h>
     45 #include <util/fs.h>
     46
     47 #include <QDir>
     48@@ -13,11 +12,6 @@
     49
     50 #include <cstdint>
     51
     52-FreespaceChecker::FreespaceChecker(Intro *_intro)
     53-{
     54-    this->intro = _intro;
     55-}
     56-
     57 void FreespaceChecker::check()
     58 {
     59     QString dataDirStr = intro->getPathToCheck();
     60diff --git a/src/qt/intro.h b/src/qt/intro.h
     61index 7b34c73b025..409ecea16d3 100644
     62--- a/src/qt/intro.h
     63+++ b/src/qt/intro.h
     64@@ -5,14 +5,14 @@
     65 #ifndef BITCOIN_QT_INTRO_H
     66 #define BITCOIN_QT_INTRO_H
     67
     68+#include <qt/freespacechecker.h>
     69+
     70 #include <QDialog>
     71 #include <QMutex>
     72 #include <QThread>
     73
     74 static const bool DEFAULT_CHOOSE_DATADIR = false;
     75
     76-class FreespaceChecker;
     77-
     78 namespace interfaces {
     79     class Node;
     80 }
     81@@ -25,7 +25,7 @@ namespace Ui {
     82   Allows the user to choose a data directory,
     83   in which the wallet and block chain will be stored.
     84  */
     85-class Intro : public QDialog
     86+class Intro : public QDialog, public FreespaceChecker::PathQuery
     87 {
     88     Q_OBJECT
     89
     90@@ -78,7 +78,7 @@ private:
     91
     92     void startThread();
     93     void checkPath(const QString &dataDir);
     94-    QString getPathToCheck();
     95+    QString getPathToCheck() override;
     96     void UpdatePruneLabels(bool prune_checked);
     97     void UpdateFreeSpaceLabel();
     98
     99diff --git a/test/lint/lint-circular-dependencies.py b/test/lint/lint-circular-dependencies.py
    100index 2ec79724d10..9554e560650 100755
    101--- a/test/lint/lint-circular-dependencies.py
    102+++ b/test/lint/lint-circular-dependencies.py
    103@@ -16,7 +16,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES = (
    104     "node/blockstorage -> validation -> node/blockstorage",
    105     "node/utxo_snapshot -> validation -> node/utxo_snapshot",
    106     "qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel",
    107-    "qt/freespacechecker -> qt/intro -> qt/freespacechecker",
    108     "qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel",
    109     "qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog",
    110     "qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel",
    
  11. qt, refactor: Move `FreespaceChecker` class into its own module 25884bd896
  12. hebasto force-pushed on Jul 29, 2025
  13. hebasto renamed this:
    refactor: Move `FreespaceChecker` class into its own module
    Move `FreespaceChecker` class into its own module
    on Jul 29, 2025
  14. hebasto removed the label Refactoring on Jul 29, 2025
  15. hebasto commented at 8:23 am on July 29, 2025: member

    @ajtowns

    Thank you for the review! Your feedback has been addressed.

  16. ajtowns commented at 11:47 am on July 30, 2025: contributor

    ACK 4542412ae063903654fc1cd95f77889bae76d61c

    nit: qt/intro.h forward decl of class FreespaceChecker is redundant since the header is included now.

  17. qt: Avoid header circular dependency 3a03f07560
  18. hebasto force-pushed on Jul 30, 2025
  19. hebasto commented at 11:58 am on July 30, 2025: member

    nit: qt/intro.h forward decl of class FreespaceChecker is redundant since the header is included now.

    Thanks! Fixed.

  20. ajtowns commented at 12:45 pm on July 30, 2025: contributor
    ACK 3a03f075606b19e411b8bd19870242e0e0b58fcb
  21. hebasto merged this on Jul 30, 2025
  22. hebasto closed this on Jul 30, 2025

  23. hebasto deleted the branch on Jul 30, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-07-31 10:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me