diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-05-21 11:21:31 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-05-26 11:15:16 +0000 |
commit | 6684686cdb8ff47376978dd4209fa9e349d37b58 (patch) | |
tree | 8aa60f89f19f2e36ebd4c837d3adca5217be7fb7 /tests/auto | |
parent | 190aca5e7d8f98b5c2242bfbe815703f3501a54a (diff) |
Restrict types from unversioned imports only by major version
The versionless import tells us that any version of the type is allowed.
We still record the major version because types have to be re-registered
for each major version. Any minor version belonging to that major
version is allowed, though. Restricting by minor version has the effect
of passing the minor version of the "host" type into grouped property
accesses. This is certainly unwelcome as the grouped type can have a
higher minor version than the host type.
Task-number: QTBUG-33179
Change-Id: I73f0f4fdaa00ac13cf91a4c21fd705c9dba070ec
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
(cherry picked from commit 5ca899164156ee49770ef3749e6d4b1567c00362)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesUnversioned.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesUnversioned.qml b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesUnversioned.qml new file mode 100644 index 0000000000..cef3ab84e6 --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesUnversioned.qml @@ -0,0 +1,5 @@ +import GroupedTest + +MyRevisioned { + grouped.prop2: 5 +} diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 50d23dd049..0556276280 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -573,6 +573,7 @@ class Grouped : public QObject { Q_OBJECT Q_PROPERTY(int prop READ prop WRITE setProp NOTIFY propChanged REVISION 1) + Q_PROPERTY(int prop2 READ prop WRITE setProp NOTIFY prop2Changed REVISION 2) public: int prop() const { return m_prop; } void setProp(int prop) @@ -580,11 +581,13 @@ public: if (prop != m_prop) { m_prop = prop; emit propChanged(prop); + emit prop2Changed(prop); } } signals: Q_REVISION(1) void propChanged(int prop); + Q_REVISION(2) void prop2Changed(int prop); private: int m_prop = 0; @@ -602,13 +605,24 @@ private: QScopedPointer<Grouped> m_grouped; }; +class MyRevisioned : public MyItem +{ + Q_OBJECT + Q_PROPERTY(int revisioned READ revisioned CONSTANT REVISION 1) +public: + int revisioned() const { return 12; } +}; + void tst_qqmlmetatype::revisionedGroupedProperties() { qmlClearTypeRegistrations(); qmlRegisterType<MyItem>("GroupedTest", 1, 0, "MyItem"); qmlRegisterType<MyItem, 1>("GroupedTest", 1, 1, "MyItem"); + qmlRegisterType<MyRevisioned>("GroupedTest", 1, 0, "MyRevisioned"); + qmlRegisterType<MyRevisioned, 1>("GroupedTest", 1, 1, "MyRevisioned"); qmlRegisterUncreatableType<Grouped>("GroupedTest", 1, 0, "Grouped", "Grouped"); qmlRegisterUncreatableType<Grouped, 1>("GroupedTest", 1, 1, "Grouped", "Grouped"); + qmlRegisterUncreatableType<Grouped, 2>("GroupedTest", 1, 2, "Grouped", "Grouped"); { QQmlEngine engine; @@ -623,6 +637,15 @@ void tst_qqmlmetatype::revisionedGroupedProperties() QQmlComponent invalid(&engine, testFileUrl("revisionedGroupedPropertiesInvalid.qml")); QVERIFY(invalid.isError()); } + + { + QQmlEngine engine; + QQmlComponent unversioned( + &engine, testFileUrl("revisionedGroupedPropertiesUnversioned.qml")); + QVERIFY2(unversioned.isReady(), qPrintable(unversioned.errorString())); + QScopedPointer<QObject> obj(unversioned.create()); + QVERIFY(!obj.isNull()); + } } void tst_qqmlmetatype::enumsInRecursiveImport_data() |