aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-03-03 12:05:18 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-03-05 07:20:08 +0100
commit464abaec05e0aa0ab699243412c50a5d5ac30742 (patch)
treee5866679c5ef631c141b1bc63db1c2dc73285cb2 /src/qml/qml/qqml.cpp
parent3d37b0baf5bb40fd97b62ad6bd8f3c2b5eb5f016 (diff)
QML: Unify treatment of invalid revisions on registration
Revisions before QML_ADDED_IN_VERSION and revisions after QML_REMOVED_IN_VERSION should both result in anonymous types. This way, you can then derive from the type in question and expose the derived type in a different set of versions. Pick-to: 6.3 Change-Id: Ia59258047fc242c809c27525bb75fd2797fe5aab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqml.cpp')
-rw-r--r--src/qml/qml/qqml.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index ff19bc4165..43cb973691 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -528,21 +528,23 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
uniqueRevisions(&revisions, type.version, added);
for (QTypeRevision revision : revisions) {
- if (revision < added)
- continue;
if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
break;
- // When removed, we still add revisions, but anonymous ones
- if (removed.isValid() && !(revision < removed)) {
+
+ assignVersions(&typeRevision, revision, type.version);
+
+ // When removed or before added, we still add revisions, but anonymous ones
+ if (typeRevision.version < added
+ || (removed.isValid() && !(typeRevision.version < removed))) {
typeRevision.elementName = nullptr;
typeRevision.create = nullptr;
+ typeRevision.userdata = nullptr;
} else {
typeRevision.elementName = elementName;
typeRevision.create = creatable ? type.create : nullptr;
typeRevision.userdata = type.userdata;
}
- assignVersions(&typeRevision, revision, type.version);
typeRevision.customParser = type.customParserFactory();
const int id = qmlregister(TypeRegistration, &typeRevision);
if (type.qmlTypeIds)
@@ -589,13 +591,14 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
uniqueRevisions(&revisions, type.version, added);
for (QTypeRevision revision : qAsConst(revisions)) {
- if (revision < added)
- continue;
if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
break;
- // When removed, we still add revisions, but anonymous ones
- if (removed.isValid() && !(revision < removed)) {
+ assignVersions(&revisionRegistration, revision, type.version);
+
+ // When removed or before added, we still add revisions, but anonymous ones
+ if (revisionRegistration.version < added
+ || (removed.isValid() && !(revisionRegistration.version < removed))) {
revisionRegistration.typeName = nullptr;
revisionRegistration.qObjectApi = nullptr;
} else {
@@ -603,7 +606,6 @@ int QQmlPrivate::qmlregister(RegistrationType type, void *data)
revisionRegistration.qObjectApi = type.qObjectApi;
}
- assignVersions(&revisionRegistration, revision, type.version);
const int id = qmlregister(SingletonRegistration, &revisionRegistration);
if (type.qmlTypeIds)
type.qmlTypeIds->append(id);