aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2026-03-10 16:07:58 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2026-05-21 12:47:55 +0000
commit23061e842d1c52bdf7d8945ac4d9cd3ecab2eb55 (patch)
tree1501d080b856280ec42f9c125be85206ab70058c /tools
parent14ddac3c7bb4b85bcdd469363b0a478bde3436e0 (diff)
qmltyperegistrar: Store unregistered referenced types as opaque types
We want to track properties and arguments. However, we do not necessarily have any information about them in metatypes.json, and even if we do, their headers might not be includable in the compiler. To handle them, we add them to qmltypes with an "opaque" marker (and don't generate any code for type registration). If a type has a meta-object, we store all information that we find, which allows qmllint and qmlls to offer the same kind of support as if the type were registered as an anonymous type. For types without a meta-object (or where the metatypes.json is missing for othe reasons), we only record that the type is known. That is still enough to avoid linter complaints for simple assignments of the same type; e.g. with smart pointers in Qt gGRPC. We mostly ignore them for now in codegen by explicitly checking for opaqueness and rejecting affected files (in case of qmltc) or functions (in case of qmlcachegen/qmlsc). If no conversion or metatype lookup is needed (e.g. when passing matching arguments to functions), we allow compilation to happen. This could be extended for property assigments, but that will require more changes. This effectively reverts commit d7904388021478adfe638c6a214903a983c7ad12. Task-number: QTBUG-143881 Fixes: QTBUG-142760 Change-Id: Ie3db559cf8e4bfa44b277d6e3e255c6fc770b83e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmltc/qmltccompiler.cpp2
-rw-r--r--tools/qmltyperegistrar/qmltyperegistrar.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp
index e5bc4bc52d..69bc730df8 100644
--- a/tools/qmltc/qmltccompiler.cpp
+++ b/tools/qmltc/qmltccompiler.cpp
@@ -541,7 +541,7 @@ void QmltcCompiler::compilePropertyInitializer(
const QString name = property.propertyName();
const auto propertyType = property.type();
- if (propertyType.isNull()) {
+ if (propertyType.isNull() || propertyType->isOpaqueType()) {
recordError(type->sourceLocation(), u"Type of property '%1' is unknown"_s.arg(name));
continue;
}
diff --git a/tools/qmltyperegistrar/qmltyperegistrar.cpp b/tools/qmltyperegistrar/qmltyperegistrar.cpp
index 0d3f3a2b67..38faf8306a 100644
--- a/tools/qmltyperegistrar/qmltyperegistrar.cpp
+++ b/tools/qmltyperegistrar/qmltyperegistrar.cpp
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
typeRegistrar.setModuleVersions(moduleVersion, pastMajorVersions,
parser.isSet(followForeignVersioningOption));
- typeRegistrar.setTypes(processor.types(), processor.foreignTypes());
+ typeRegistrar.setTypes(processor.types(), processor.foreignTypes(), processor.opaqueTypes());
if (!parser.isSet(jsroot)) {
if (module.isEmpty()) {