aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlproperty
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-10-22 16:47:01 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-10-23 10:29:06 +0200
commit40a6845bcce22aca96e1dee26360bdff3e9520fb (patch)
tree4418dd6bffa51e8d2396b764912286e5013e2385 /tests/auto/qml/qqmlproperty
parente2764c722571025835e41632637d1421ba44fb02 (diff)
Fix assignment to QObject pointer properties
This commit ammends 59ed8c355b99df0b949003a438ab850274261aa0 to always query the Qt meta-type registry to retrieve the QMetaObject for a QObject pointer type. Change-Id: I70d876a5acfa23967fd1a57c96fcd5ac853eaf49 Task-number: QTBUG-39614 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlproperty')
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 6cd1eafafd..62ccec5794 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -1157,6 +1157,17 @@ void tst_qqmlproperty::read()
QVERIFY(v.canConvert(QMetaType::QObjectStar));
QVERIFY(qvariant_cast<QObject *>(v) == o.qObject());
}
+ {
+ QQmlEngine engine;
+ PropertyObject o;
+ QQmlProperty p(&o, "qObject", &engine);
+ QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object);
+
+ QCOMPARE(p.propertyType(), qMetaTypeId<MyQObject*>());
+ QVariant v = p.read();
+ QVERIFY(v.canConvert(QMetaType::QObjectStar));
+ QVERIFY(qvariant_cast<QObject *>(v) == o.qObject());
+ }
// Object property
{
@@ -1432,6 +1443,23 @@ void tst_qqmlproperty::write()
QCOMPARE(newData.value<QObject*>(), newObject);
QCOMPARE(newData.value<MyQObject*>(), newObject);
}
+ {
+ QQmlEngine engine;
+ PropertyObject o;
+ QQmlProperty p(&o, QString("qObject"), &engine);
+ QCOMPARE(o.qObject(), (QObject*)0);
+ QObject *newObject = new MyQObject(this);
+ QCOMPARE(p.write(QVariant::fromValue(newObject)), true);
+ QCOMPARE(o.qObject(), newObject);
+ QVariant data = p.read();
+ QCOMPARE(data.value<QObject*>(), newObject);
+ QCOMPARE(data.value<MyQObject*>(), newObject);
+ // Incompatible types can not be written.
+ QCOMPARE(p.write(QVariant::fromValue(new MyQmlObject(this))), false);
+ QVariant newData = p.read();
+ QCOMPARE(newData.value<QObject*>(), newObject);
+ QCOMPARE(newData.value<MyQObject*>(), newObject);
+ }
}
void tst_qqmlproperty::reset()