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

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

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

    <!--85328a0da195eb286784d51f73fa0af9-->

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

    <details><summary>Hints</summary>

    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.

    </details>

  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:

    diff --git a/src/qt/freespacechecker.h b/src/qt/freespacechecker.h
    index d3a61a11571..214324be7c8 100644
    --- a/src/qt/freespacechecker.h
    +++ b/src/qt/freespacechecker.h
    @@ -9,8 +9,6 @@
     #include <QString>
     #include <QtGlobal>
    
    -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,12 @@ 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 +43,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/freespacechecker.cpp b/src/qt/freespacechecker.cpp
    index 28c55baf7d0..c259facb782 100644
    --- a/src/qt/freespacechecker.cpp
    +++ b/src/qt/freespacechecker.cpp
    @@ -5,7 +5,6 @@
     #include <qt/freespacechecker.h>
    
     #include <qt/guiutil.h>
    -#include <qt/intro.h>
     #include <util/fs.h>
    
     #include <QDir>
    @@ -13,11 +12,6 @@
    
     #include <cstdint>
    
    -FreespaceChecker::FreespaceChecker(Intro *_intro)
    -{
    -    this->intro = _intro;
    -}
    -
     void FreespaceChecker::check()
     {
         QString dataDirStr = intro->getPathToCheck();
    diff --git a/src/qt/intro.h b/src/qt/intro.h
    index 7b34c73b025..409ecea16d3 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 <qt/freespacechecker.h>
    +
     #include <QDialog>
     #include <QMutex>
     #include <QThread>
    
     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",
    
  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: 2026-04-27 21:20 UTC

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