diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-20 12:51:02 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-21 15:47:10 +0000 |
commit | 30db7d94e002b5c5b29820050a2220ef06afa54c (patch) | |
tree | d132dae16610cfdd9ef71118ee377dadca1d37fc /tests/auto/qml | |
parent | ba2ff45daae4e6167f7719ab1466023093031a75 (diff) |
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 <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml')
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml new file mode 100644 index 0000000000..df6d801cde --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesInvalid.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import GroupedTest 1.0 + +MyItem { + grouped.prop: 5 +} diff --git a/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml new file mode 100644 index 0000000000..b7ea017acf --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/revisionedGroupedPropertiesValid.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import GroupedTest 1.1 + +MyItem { + grouped.prop: 5 +} 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<Grouped> m_grouped; +}; + +void tst_qqmlmetatype::revisionedGroupedProperties() +{ + qmlClearTypeRegistrations(); + qmlRegisterType<MyItem>("GroupedTest", 1, 0, "MyItem"); + qmlRegisterType<MyItem, 1>("GroupedTest", 1, 1, "MyItem"); + qmlRegisterUncreatableType<Grouped>("GroupedTest", 1, 0, "Grouped", "Grouped"); + qmlRegisterUncreatableType<Grouped, 1>("GroupedTest", 1, 1, "Grouped", "Grouped"); + + { + QQmlEngine engine; + QQmlComponent valid(&engine, testFileUrl("revisionedGroupedPropertiesValid.qml")); + QVERIFY(valid.isReady()); + QScopedPointer<QObject> 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" |