musescore / musescore/muse_framework

Missing `#include` directives for Qt types used by value or in template instantiations

Open
#272 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12
Forks
57
Avg merge
1d 22h
Merged PRs (30d)
37

Description

I've been trying to build Audacity 4 against KDE's Qt 6.11 and had to include a series of patches to make it work. What follows is an AI-generated report of one of such issues. I see no contributing or AI guidelines so I hope this is acceptable.


Multiple source files in the muse framework use Qt types by value, in std::unique_ptr destructors, or in MOC-generated QMetaType registrations while only having a forward declaration of those types. These are latent C++ bugs that compile by accident when the full type definition happens to be transitively included through other headers, but fail when those transitive includes are not present.

Environment

  • muse framework commit: 3c5512eb8ee1a863a6123e62bd75a6ab55045752
  • Consumer: Audacity 4.0.0 (which uses muse as a git submodule)
  • Qt: Built from the KDE Qt fork (the source of the kde-qt6-core24-sdk snap), version 6.11.1
  • Compiler: GCC 13.2.0 (Ubuntu 24.04)

Root cause

Many files forward-declare a Qt class (e.g. class QFile;) and then use it in a context that requires the complete type definition:

  • std::map<K, std::unique_ptr<QFile>> — the map's destructor instantiates ~unique_ptr<QFile>, which requires QFile to be complete.
  • Q_PROPERTY(QVariant ...) — MOC generates QMetaType registration code that requires QVariant to be complete.
  • Stack-allocated variables (e.g. QTimer timer;) — require the complete type.
  • Q_INVOKABLE QWindow* foo() — MOC registers a pointer metatype requiring the pointee to be complete.

With upstream Qt (from the Qt Online Installer, used by MuseScore), these compile because the full definitions are transitively included via other headers. The KDE Qt fork (invent.kde.org/qt/qt/) has progressively cleaned up transitive includes (part of Qt's ongoing "include hygiene" effort), which exposes these latent bugs. As upstream Qt also cleans up transitive includes, these will break for everyone.

Affected files and required fixes

File Missing include Type / context
framework/global/io/internal/filesystem.h <QFile> std::map<..., std::unique_ptr<QFile>> (also remove the class QFile; forward declaration)
framework/global/api/apiutils.h <QMetaEnum> const QMetaEnum& parameter
framework/ui/api/themeapi.cpp <QFontMetrics> QFontMetricsF (needs QFontMetrics base)
framework/ui/view/qmldataformatter.cpp <QLocale> QLocale locale;
framework/ui/view/widgetstyle.cpp <QPainter> QPainter* dereferenced
framework/cloud/internal/abstractcloudservice.cpp <QTimer> QTimer timer;
framework/multiwindows/internal/singleprocess/singleprocessprovider.cpp <QCoreApplication> QCoreApplication::...
framework/extensions/internal/extensionsession.h "../extensionstypes.h" const Manifest& parameter
framework/interactive/api/interactiveapi.cpp <QMetaEnum> QMetaEnum used by value
framework/ui/qml/Muse/Ui/initialletternavigation.h <QTimer> QTimer m_inputBufferTimer; member field
framework/ui/qml/Muse/Ui/initialletternavigation.cpp <QRegularExpression> const QRegularExpression
framework/interactive/internal/interactive.cpp <QQmlEngine> QQmlEngine::...
framework/uicomponents/qml/Muse/UiComponents/abstracttableviewmodel.cpp <QTimer> QTimer::singleShot(...)
framework/uicomponents/qml/Muse/UiComponents/filteredflyoutmodel.h <QVariant> Q_PROPERTY(QVariant ...)
framework/multiwindows/qml/Muse/MultiWindows/multiinstancesdevmodel.h <QVariant> Q_PROPERTY(QList<QVariant> ...)
framework/uicomponents/qml/Muse/UiComponents/polylineplot.cpp <QCursor> setCursor(Qt::CrossCursor)
framework/interactive/qml/Muse/Interactive/interactiveprovidermodel.h <QWindow> Q_INVOKABLE QWindow* (MOC pointer metatype)

Suggested fix

For each file, add the missing #include directive. In filesystem.h, also remove the class QFile; forward declaration since the full #include <QFile> makes it unnecessary.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the affected files listed in the report, especially framework/global/io/internal/filesystem.h, and inspect each forward declaration and use site. Add the specified direct includes, remove the obsolete QFile declaration, then build the muse framework with Qt 6.11 and confirm the listed files compile without relying on transitive includes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.