aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-02 14:11:24 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-02 14:32:35 +0100
commit1b93a1d86549347566e1a7645c0501e5c9f6aa0a (patch)
tree25bab0d6ef18650576864ed245ba95a628169816 /src
parentecd54e68b90ad7022d1bdb71f1c1640ab392adae (diff)
qmltyperegistrar: Fix handling of default properties
Default properties are always local. There is no way to declare a default property for a foreign type as the default property is queried directly from the classinfo at runtime. Change-Id: I30efb6fba190957ac2a4ad86da437f209cd1f3ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.cpp61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp
index 82c1c31ec2..90f7565e5e 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.cpp
+++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp
@@ -113,7 +113,7 @@ void QmlTypesClassDescription::collectLocalAnonymous(
for (const QJsonValue &classInfo : classInfos) {
const QJsonObject obj = classInfo.toObject();
if (obj[QStringLiteral("name")].toString() == QStringLiteral("DefaultProperty"))
- defaultProp = obj[obj[QStringLiteral("value")].toString()].toString();
+ defaultProp = obj[QStringLiteral("value")].toString();
}
collectInterfaces(classDef);
@@ -129,6 +129,7 @@ void QmlTypesClassDescription::collect(
const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray();
const QString classDefName = classDef->value(QLatin1String("className")).toString();
+ QString foreignTypeName;
for (const QJsonValue &classInfo : classInfos) {
const QJsonObject obj = classInfo.toObject();
const QString name = obj[QLatin1String("name")].toString();
@@ -173,36 +174,44 @@ void QmlTypesClassDescription::collect(
if (value == QLatin1String("true"))
isSingleton = true;
} else if (name == QLatin1String("QML.Foreign")) {
- if (const QJsonObject *other = findType(foreign, value)) {
- classDef = other;
- // Foreign type can have a default property or an attached types
- const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray();
- for (const QJsonValue &classInfo : classInfos) {
- const QJsonObject obj = classInfo.toObject();
- const QString foreignName = obj[QLatin1String("name")].toString();
- const QString foreignValue = obj[QLatin1String("value")].toString();
- if (defaultProp.isEmpty() && foreignName == QLatin1String("DefaultProperty")) {
- defaultProp = foreignValue;
- } else if (foreignName == QLatin1String("QML.Attached")) {
- attachedType = foreignValue;
- collectRelated(foreignValue, types, foreign, defaultRevision);
- } else if (foreignName == QLatin1String("QML.Extended")) {
- extensionType = foreignValue;
- collectRelated(foreignValue, types, foreign, defaultRevision);
- } else if (foreignName == QLatin1String("QML.Sequence")) {
- sequenceValueType = foreignValue;
- collectRelated(foreignValue, types, foreign, defaultRevision);
- }
- }
- } else {
- className = value;
- classDef = nullptr;
- }
+ foreignTypeName = value;
} else if (name == QLatin1String("QML.Root")) {
isRootClass = true;
}
}
+ if (!foreignTypeName.isEmpty()) {
+ if (const QJsonObject *other = findType(foreign, foreignTypeName)) {
+ classDef = other;
+
+ // Default properties are always local.
+ defaultProp.clear();
+
+ // Foreign type can have a default property or an attached types
+ const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray();
+ for (const QJsonValue &classInfo : classInfos) {
+ const QJsonObject obj = classInfo.toObject();
+ const QString foreignName = obj[QLatin1String("name")].toString();
+ const QString foreignValue = obj[QLatin1String("value")].toString();
+ if (defaultProp.isEmpty() && foreignName == QLatin1String("DefaultProperty")) {
+ defaultProp = foreignValue;
+ } else if (foreignName == QLatin1String("QML.Attached")) {
+ attachedType = foreignValue;
+ collectRelated(foreignValue, types, foreign, defaultRevision);
+ } else if (foreignName == QLatin1String("QML.Extended")) {
+ extensionType = foreignValue;
+ collectRelated(foreignValue, types, foreign, defaultRevision);
+ } else if (foreignName == QLatin1String("QML.Sequence")) {
+ sequenceValueType = foreignValue;
+ collectRelated(foreignValue, types, foreign, defaultRevision);
+ }
+ }
+ } else {
+ className = foreignTypeName;
+ classDef = nullptr;
+ }
+ }
+
if (classDef) {
if (mode == RelatedType || !elementName.isEmpty()) {
collectExtraVersions(classDef, QString::fromLatin1("properties"), revisions);