From e9a6c1d4e30d6adb2190d52bebb7fecd2b539e82 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 19 Jan 2016 15:37:26 +0100 Subject: Don't check for revisions when assigning to grouped properties This leads to wrong behavior in some cases, where we reject valid revisions, and there is probably no case, where this could lead to a conflict for the user of the API. Change-Id: I1614332cf4c07c6a227551612331dd69b2ae71f3 Task-number: QTBUG-40043 Reviewed-by: Simon Hausmann --- .../qml/qqmlecmascript/data/metaobjectRevision5.qml | 12 ++++++++++++ tests/auto/qml/qqmlecmascript/testtypes.cpp | 1 + tests/auto/qml/qqmlecmascript/testtypes.h | 17 +++++++++++++++++ tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 9 +++++++++ 4 files changed, 39 insertions(+) create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevision5.qml (limited to 'tests/auto/qml/qqmlecmascript') diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevision5.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision5.qml new file mode 100644 index 0000000000..0493a7c0b9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision5.qml @@ -0,0 +1,12 @@ +import Qt.test 1.1 +import QtQuick 2.0 + +MyItemUsingRevisionedObject { + property real test + + revisioned.prop1: 10 + revisioned.prop2: 1 + + Component.onCompleted: test = revisioned.prop1 + revisioned.prop2 +} + diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index 285158a4ea..b9e088d64c 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -452,6 +452,7 @@ void registerTypes() qmlRegisterType("Qt.test",1,0,"MyRevisionedSubclass"); // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 qmlRegisterType("Qt.test",1,1,"MyRevisionedSubclass"); + qmlRegisterType("Qt.test", 1, 0, "MyItemUsingRevisionedObject"); #ifndef QT_NO_WIDGETS qmlRegisterExtendedType("Qt.test",1,0,"QWidget"); diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index eb4a3147d3..5603356ef0 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1084,10 +1084,27 @@ protected: qreal m_p4; }; + +class MyItemUsingRevisionedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(MyRevisionedClass *revisioned READ revisioned) + +public: + MyItemUsingRevisionedObject() { + m_revisioned = new MyRevisionedClass; + } + + MyRevisionedClass *revisioned() const { return m_revisioned; } +private: + MyRevisionedClass *m_revisioned; +}; + QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered) QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered) QML_DECLARE_TYPE(MyRevisionedClass) QML_DECLARE_TYPE(MyRevisionedSubclass) +QML_DECLARE_TYPE(MyItemUsingRevisionedObject) Q_DECLARE_METATYPE(MyQmlObject::MyType) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index b30dfcbd0b..a208bf5634 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -6578,6 +6578,15 @@ void tst_qqmlecmascript::revision() QCOMPARE(object->property("test").toReal(), 11.); delete object; } + + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevision5.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toReal(), 11.); + delete object; + } } void tst_qqmlecmascript::realToInt() -- cgit v1.2.3