From 30db7d94e002b5c5b29820050a2220ef06afa54c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 20 Feb 2019 12:51:02 +0100 Subject: QML: Pass type minor version when creating property data Depending on the type minor version recursive properties should be available or not. Check for that when resolving grouped properties. Fixes: QTBUG-33179 Change-Id: Id8f62befdc4a29d879710499e19d3d289bd18775 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp') diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 7139a1c952..ce72f40dcc 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -66,6 +66,7 @@ private slots: void normalizeUrls(); void unregisterAttachedProperties(); + void revisionedGroupedProperties(); }; class TestType : public QObject @@ -572,6 +573,62 @@ void tst_qqmlmetatype::unregisterAttachedProperties() } } +class Grouped : public QObject +{ + Q_OBJECT + Q_PROPERTY(int prop READ prop WRITE setProp NOTIFY propChanged REVISION 1) +public: + int prop() const { return m_prop; } + void setProp(int prop) + { + if (prop != m_prop) { + m_prop = prop; + emit propChanged(prop); + } + } + +signals: + Q_REVISION(1) void propChanged(int prop); + +private: + int m_prop = 0; +}; + +class MyItem : public QObject +{ + Q_OBJECT + Q_PROPERTY(Grouped *grouped READ grouped CONSTANT) +public: + MyItem() : m_grouped(new Grouped) {} + Grouped *grouped() const { return m_grouped.data(); } + +private: + QScopedPointer m_grouped; +}; + +void tst_qqmlmetatype::revisionedGroupedProperties() +{ + qmlClearTypeRegistrations(); + qmlRegisterType("GroupedTest", 1, 0, "MyItem"); + qmlRegisterType("GroupedTest", 1, 1, "MyItem"); + qmlRegisterUncreatableType("GroupedTest", 1, 0, "Grouped", "Grouped"); + qmlRegisterUncreatableType("GroupedTest", 1, 1, "Grouped", "Grouped"); + + { + QQmlEngine engine; + QQmlComponent valid(&engine, testFileUrl("revisionedGroupedPropertiesValid.qml")); + QVERIFY(valid.isReady()); + QScopedPointer obj(valid.create()); + QVERIFY(!obj.isNull()); + } + + { + QQmlEngine engine; + QQmlComponent invalid(&engine, testFileUrl("revisionedGroupedPropertiesInvalid.qml")); + QVERIFY(invalid.isError()); + } +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" -- cgit v1.2.3