From 96c35a84d30b5b5cdf8feac4959891ad0bfed6a8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 20 Jul 2015 14:21:08 +0200 Subject: fix readonly metaproperties (revealed by compiler warning) Found thanks to -Wparentheses + gcc 5.1 Change-Id: Iad784a26d268b85f7c67623fd63f0b097a9f29f9 Reviewed-by: Simon Hausmann --- .../auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml | 8 ++++++++ tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml b/tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml new file mode 100644 index 0000000000..253d61d1da --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/readonlyPrimitiveVsVar.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + readonly property var r_var: 1; + readonly property int r_int: 1; + property var w_var: 1; + property int w_int: 1; +} diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index c4b2325843..a8b06ffa71 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -146,6 +146,7 @@ private slots: void warnOnInvalidBinding(); void registeredCompositeTypeProperty(); void deeplyNestedObject(); + void readOnlyDynamicProperties(); void copy(); private: @@ -2039,6 +2040,20 @@ void tst_qqmlproperty::deeplyNestedObject() QCOMPARE(p.read(), QVariant(14)); } +void tst_qqmlproperty::readOnlyDynamicProperties() +{ + QQmlComponent comp(&engine, testFileUrl("readonlyPrimitiveVsVar.qml")); + QObject *obj = comp.create(); + QVERIFY(obj != 0); + + QVERIFY(!obj->metaObject()->property(obj->metaObject()->indexOfProperty("r_var")).isWritable()); + QVERIFY(!obj->metaObject()->property(obj->metaObject()->indexOfProperty("r_int")).isWritable()); + QVERIFY(obj->metaObject()->property(obj->metaObject()->indexOfProperty("w_var")).isWritable()); + QVERIFY(obj->metaObject()->property(obj->metaObject()->indexOfProperty("w_int")).isWritable()); + + delete obj; +} + void tst_qqmlproperty::initTestCase() { QQmlDataTest::initTestCase(); -- cgit v1.2.3