From 164e559c8a7a34aa46ef7563a19100f81a1cade4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 16 Jan 2020 15:00:36 +0100 Subject: Process major versions as part of Q_REVISION Retrieve the major version from the meta object revisions and use them to register types and generate qmltypes files. Change-Id: I35da8963457660d1a49ba9063574e1a68057a7ba Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlmetatypedata.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/qml/qml/qqmlmetatypedata.cpp') diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp index 51d944e771..a34a0c1ae4 100644 --- a/src/qml/qml/qqmlmetatypedata.cpp +++ b/src/qml/qml/qqmlmetatypedata.cpp @@ -78,9 +78,9 @@ void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv) priv->release(); } -bool QQmlMetaTypeData::registerModuleTypes(const QQmlMetaTypeData::VersionedUri &versionedUri) +bool QQmlMetaTypeData::registerModuleTypes(const QString &uri) { - auto function = moduleTypeRegistrationFunctions.constFind(versionedUri); + auto function = moduleTypeRegistrationFunctions.constFind(uri); if (function != moduleTypeRegistrationFunctions.constEnd()) { (*function)(); return true; @@ -138,10 +138,15 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, QTypeRe const QMetaObject *metaObject = type.metaObject(); + const QTypeRevision combinedVersion = version.hasMajorVersion() + ? version + : (version.hasMinorVersion() + ? QTypeRevision::fromVersion(type.version().majorVersion(), + version.minorVersion()) + : type.version()); + while (metaObject) { - QQmlType t = QQmlMetaType::qmlType(metaObject, type.module(), - QTypeRevision::fromVersion(type.version().majorVersion(), - version.minorVersion())); + QQmlType t = QQmlMetaType::qmlType(metaObject, type.module(), combinedVersion); if (t.isValid()) { maxMinorVersion = qMax(maxMinorVersion, t.version().minorVersion()); types << t; @@ -152,13 +157,14 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, QTypeRe metaObject = metaObject->superClass(); } - const QTypeRevision maxVersion = QTypeRevision::fromVersion(version.majorVersion(), maxMinorVersion); + const QTypeRevision maxVersion = QTypeRevision::fromVersion(combinedVersion.majorVersion(), + maxMinorVersion); if (QQmlPropertyCache *pc = propertyCacheForVersion(type.index(), maxVersion)) { setPropertyCacheForVersion(type.index(), maxVersion, pc); return pc; } - QQmlPropertyCache *raw = propertyCache(type.metaObject(), version); + QQmlPropertyCache *raw = propertyCache(type.metaObject(), combinedVersion); bool hasCopied = false; @@ -230,7 +236,7 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, QTypeRe if (hasCopied) raw->release(); - if (version.minorVersion() != maxMinorVersion) + if (version != maxVersion) setPropertyCacheForVersion(type.index(), maxVersion, raw); return raw; -- cgit v1.2.3