aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlmetatype
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-05-21 11:21:31 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-05-26 10:19:48 +0200
commit5ca899164156ee49770ef3749e6d4b1567c00362 (patch)
treee17911bbd707b789028e77b5ce010eeb9a746ab0 /tests/auto/qml/qqmlmetatype
parent015e6473b16838a202b8388a62c6cacc1bf3571e (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 Pick-to: 6.1 Change-Id: I73f0f4fdaa00ac13cf91a4c21fd705c9dba070ec Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlmetatype')
-rw-r--r--tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesUnversioned.qml5
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp23
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 7f81059b58..4d2e8c2b5d 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -630,6 +630,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)
@@ -637,11 +638,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;
@@ -659,13 +662,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;
@@ -680,6 +694,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()