diff options
Diffstat (limited to 'src/qmltyperegistrar/qmltypesclassdescription.cpp')
-rw-r--r-- | src/qmltyperegistrar/qmltypesclassdescription.cpp | 61 |
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); |