aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlpropertycache_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-01-27 17:31:06 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-17 14:44:17 +0100
commit1eb20d70619cc896fc283bd6605b257a8750c518 (patch)
tree1d308932d38759a643d8eef49b211329a2cd5467 /src/qml/qml/qqmlpropertycache_p.h
parente3c64aff6579f04353608d4b218f031d9137d3f4 (diff)
Allow partial and absent version specifiers in import statements
An import statement without version specifier imports the latest version available, one with only a major version imports the latest minor version from that major version. Task-number: QTBUG-71278 Change-Id: I43907ae4e1052be533039d545de5391c41d38307 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertycache_p.h')
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 9e6eaf9778..6038056991 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -354,9 +354,23 @@ QQmlPropertyCache::overrideData(QQmlPropertyData *data) const
bool QQmlPropertyCache::isAllowedInRevision(QQmlPropertyData *data) const
{
- return (data->metaObjectOffset() == -1 && data->revision() == QTypeRevision::zero())
- || (allowedRevisionCache[data->metaObjectOffset()].toEncodedVersion<quint16>()
- >= data->revision().toEncodedVersion<quint16>());
+ const QTypeRevision requested = data->revision();
+ const int offset = data->metaObjectOffset();
+ if (offset == -1 && requested == QTypeRevision::zero())
+ return true;
+
+ Q_ASSERT(offset >= 0);
+ Q_ASSERT(offset < allowedRevisionCache.length());
+ const QTypeRevision allowed = allowedRevisionCache[data->metaObjectOffset()];
+
+ if (requested.hasMajorVersion()) {
+ if (requested.majorVersion() > allowed.majorVersion())
+ return false;
+ if (requested.majorVersion() < allowed.majorVersion())
+ return true;
+ }
+
+ return !requested.hasMinorVersion() || requested.minorVersion() <= allowed.minorVersion();
}
int QQmlPropertyCache::propertyCount() const