aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatypedata.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-01-22 13:12:56 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-02-03 15:22:12 +0100
commit789929f939a60462373beae37ab4373809095cff (patch)
treed3ee9dadb901213940ba61748f303fd34ccab424 /src/qml/qml/qqmlmetatypedata.cpp
parent8ba73c0134f162afd9aa83b731a8147728642385 (diff)
Use QTypeRevision for all versions and revisions
In many places we carry major and minor versions or revisions that are loosely coupled to minor versions. As the Qt minor version resets now, we need to handle these things more systematically. In particular, we need to add a "major" part to revisions. QTypeRevision can express the current major/minor pairs more efficiently and can also be used to add a major version to revisions. This change does not change the semantics, yet, but only replaces the types. Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlmetatypedata.cpp')
-rw-r--r--src/qml/qml/qqmlmetatypedata.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp
index ed885eaa97..51d944e771 100644
--- a/src/qml/qml/qqmlmetatypedata.cpp
+++ b/src/qml/qml/qqmlmetatypedata.cpp
@@ -88,28 +88,28 @@ bool QQmlMetaTypeData::registerModuleTypes(const QQmlMetaTypeData::VersionedUri
return false;
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCacheForMinorVersion(int index, int minorVersion) const
+QQmlPropertyCache *QQmlMetaTypeData::propertyCacheForVersion(int index, QTypeRevision version) const
{
return (index < typePropertyCaches.length())
- ? typePropertyCaches.at(index).value(minorVersion).data()
+ ? typePropertyCaches.at(index).value(version).data()
: nullptr;
}
-void QQmlMetaTypeData::setPropertyCacheForMinorVersion(int index, int minorVersion,
- QQmlPropertyCache *cache)
+void QQmlMetaTypeData::setPropertyCacheForVersion(int index, QTypeRevision version,
+ QQmlPropertyCache *cache)
{
if (index >= typePropertyCaches.length())
typePropertyCaches.resize(index + 1);
- typePropertyCaches[index][minorVersion] = cache;
+ typePropertyCaches[index][version] = cache;
}
-void QQmlMetaTypeData::clearPropertyCachesForMinorVersion(int index)
+void QQmlMetaTypeData::clearPropertyCachesForVersion(int index)
{
if (index < typePropertyCaches.length())
typePropertyCaches[index].clear();
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject, int minorVersion)
+QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject, QTypeRevision version)
{
if (QQmlPropertyCache *rv = propertyCaches.value(metaObject))
return rv;
@@ -119,29 +119,31 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject
propertyCaches.insert(metaObject, rv);
return rv;
}
- QQmlPropertyCache *super = propertyCache(metaObject->superClass(), minorVersion);
- QQmlPropertyCache *rv = super->copyAndAppend(metaObject, minorVersion);
+ QQmlPropertyCache *super = propertyCache(metaObject->superClass(), version);
+ QQmlPropertyCache *rv = super->copyAndAppend(metaObject, version);
propertyCaches.insert(metaObject, rv);
return rv;
}
-QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int minorVersion)
+QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, QTypeRevision version)
{
Q_ASSERT(type.isValid());
- if (QQmlPropertyCache *pc = propertyCacheForMinorVersion(type.index(), minorVersion))
+ if (QQmlPropertyCache *pc = propertyCacheForVersion(type.index(), version))
return pc;
QVector<QQmlType> types;
- int maxMinorVersion = 0;
+ quint8 maxMinorVersion = 0;
const QMetaObject *metaObject = type.metaObject();
while (metaObject) {
- QQmlType t = QQmlMetaType::qmlType(metaObject, type.module(), type.majorVersion(), minorVersion);
+ QQmlType t = QQmlMetaType::qmlType(metaObject, type.module(),
+ QTypeRevision::fromVersion(type.version().majorVersion(),
+ version.minorVersion()));
if (t.isValid()) {
- maxMinorVersion = qMax(maxMinorVersion, t.minorVersion());
+ maxMinorVersion = qMax(maxMinorVersion, t.version().minorVersion());
types << t;
} else {
types << QQmlType();
@@ -150,12 +152,13 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
metaObject = metaObject->superClass();
}
- if (QQmlPropertyCache *pc = propertyCacheForMinorVersion(type.index(), maxMinorVersion)) {
- setPropertyCacheForMinorVersion(type.index(), minorVersion, pc);
+ const QTypeRevision maxVersion = QTypeRevision::fromVersion(version.majorVersion(), maxMinorVersion);
+ if (QQmlPropertyCache *pc = propertyCacheForVersion(type.index(), maxVersion)) {
+ setPropertyCacheForVersion(type.index(), maxVersion, pc);
return pc;
}
- QQmlPropertyCache *raw = propertyCache(type.metaObject(), minorVersion);
+ QQmlPropertyCache *raw = propertyCache(type.metaObject(), version);
bool hasCopied = false;
@@ -164,7 +167,7 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
if (!currentType.isValid())
continue;
- int rev = currentType.metaObjectRevision();
+ QTypeRevision rev = currentType.metaObjectRevision();
int moIndex = types.count() - 1 - ii;
if (raw->allowedRevision(moIndex) != rev) {
@@ -222,13 +225,13 @@ QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QQmlType &type, int min
}
#endif
- setPropertyCacheForMinorVersion(type.index(), minorVersion, raw);
+ setPropertyCacheForVersion(type.index(), version, raw);
if (hasCopied)
raw->release();
- if (minorVersion != maxMinorVersion)
- setPropertyCacheForMinorVersion(type.index(), maxMinorVersion, raw);
+ if (version.minorVersion() != maxMinorVersion)
+ setPropertyCacheForVersion(type.index(), maxVersion, raw);
return raw;
}