diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-07-11 15:52:57 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2025-08-05 21:02:16 +0000 |
| commit | 7f36c0a74f058cccd323dcf38834e272343cdc6a (patch) | |
| tree | ab20138fc64a991fb234ccd4595cf2d26aaff4cc /tools | |
| parent | afef7ff31a37293877920bff9a30e66c14a57ef7 (diff) | |
qmltc: Don't crash on missing type information
Pick-to: 6.9 6.8
Fixes: QTBUG-136355
Change-Id: I0cf56674b451187a3483f4dfefbf6e1ccb275d04
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
(cherry picked from commit 527e108c9f80c7f5f48e9c50d579f07826ceb620)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/qmltc/qmltccompiler.cpp | 21 | ||||
| -rw-r--r-- | tools/qmltc/qmltccompiler.h | 2 |
2 files changed, 17 insertions, 6 deletions
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp index 7ad038aaa4..5a501f41ee 100644 --- a/tools/qmltc/qmltccompiler.cpp +++ b/tools/qmltc/qmltccompiler.cpp @@ -536,20 +536,28 @@ static Iterator partitionBindings(Iterator first, Iterator last) // and otherwise falls back to a the more generic // `QObject::setProperty` for properties where a WRITE method is not // available or in scope. -static void compilePropertyInitializer(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) { - static auto isFromExtension = [](const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &scope) { - return scope->ownerOfProperty(scope, property.propertyName()).extensionSpecifier != QQmlJSScope::NotExtension; +void QmltcCompiler::compilePropertyInitializer( + QmltcType ¤t, const QQmlJSScope::ConstPtr &type) { + static auto isFromExtension + = [](const QQmlJSMetaProperty &property, const QQmlJSScope::ConstPtr &scope) { + return scope->ownerOfProperty(scope, property.propertyName()).extensionSpecifier + != QQmlJSScope::NotExtension; }; current.propertyInitializer.constructor.initializerList << u"component{component}"_s; - auto properties = type->properties().values(); - for (auto& property: properties) { + const auto properties = type->properties().values(); + for (const auto &property: properties) { if (property.index() == -1) continue; if (property.isPrivate()) continue; if (!property.isWritable() && !qIsReferenceTypeList(property)) continue; const QString name = property.propertyName(); + const auto propertyType = property.type(); + if (propertyType.isNull()) { + recordError(type->sourceLocation(), u"Type of property '%1' is unknown"_s.arg(name)); + continue; + } current.propertyInitializer.propertySetters.emplace_back(); auto& compiledSetter = current.propertyInitializer.propertySetters.back(); @@ -560,7 +568,8 @@ static void compilePropertyInitializer(QmltcType ¤t, const QQmlJSScope::Co if (qIsReferenceTypeList(property)) { compiledSetter.parameterList.emplaceBack( - QQmlJSUtils::constRefify(u"QList<%1*>"_s.arg(property.type()->valueType()->internalName())), + QQmlJSUtils::constRefify( + u"QList<%1*>"_s.arg(propertyType->valueType()->internalName())), name + u"_", QString() ); } else { diff --git a/tools/qmltc/qmltccompiler.h b/tools/qmltc/qmltccompiler.h index a8254dc315..bbaaa55255 100644 --- a/tools/qmltc/qmltccompiler.h +++ b/tools/qmltc/qmltccompiler.h @@ -150,6 +150,8 @@ private: const QQmlJSScope::ConstPtr &propertyType, const BindingAccessorData &accessor); + void compilePropertyInitializer(QmltcType ¤t, const QQmlJSScope::ConstPtr &type); + /*! \internal Helper structure that acts as a key in a hash-table of |
