Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.5.8, 6.8.2, 6.9.0 Beta2
-
Windows 10 22H2, MSVC 2022 x64, MinGW x64
-
fd88f44c1 (dev), 0f4cd43bc (6.9), c170381f3 (dev), aed070931 (6.8)
Description
See attached project. The CppObj class contains both Q_OBJECT and QML_ELEMENT. The relevant headers for those macros are precompiled but not explicitly #include-d.
The Clang code model is happy with the C++ code (when using MSVC) and the project does not produce any compile-time errors. But, it contains runtime errors:
- CppObj::metaObject() is implemented by moc and can be called in C++ (Expected)
- CppObj is not registered as a QML type and is invisible to the QML engine (Not Expected)
Workaround
Explicitly #include-ing the PCH (or <qqmlintegration.h>) fixes the error.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-134148 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
628594,9 | Warn about QML registration macro without include | dev | qt/qtbase | Status: MERGED | +2 | 0 |
628857,5 | moc: Add a hidden option to make QML macro warnings fatal | dev | qt/qtbase | Status: MERGED | +2 | 0 |
629490,2 | Warn about QML registration macro without include | 6.9 | qt/qtbase | Status: MERGED | +2 | 0 |
629531,2 | Warn about QML registration macro without include | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |
630330,2 | WIP: qt_add_qml_module: Set fatal-qml-macro-warning moc option | dev | qt/qtdeclarative | Status: DEFERRED | -2 | -1 |