aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-03-23 21:32:38 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-03-30 14:18:18 +0200
commitdff7689a016d63fbaf1abc6f00a768dbfb8ec095 (patch)
tree6f0b67ce5d6dec279c0bbf62f014955cd0f25e32 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
parent9f2c5aa2efd24507f4508889911873bc1c9d301e (diff)
Add support for binding directly to QProperty instances
Avoid going through externally managed bindings and instead allocate a more lightweight property binding. It's basically a QQmlJavaScriptExpression and one pointer plus the overhead of QPropertyBindingPrivate. Change-Id: I1530330926d351b61f2b3bbad39301c628a8bef1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index b3e4296a13..fbb344f9a0 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -381,6 +381,7 @@ private slots:
void getThisObject();
void semicolonAfterProperty();
void hugeStack();
+ void bindingOnQProperty();
void gcCrashRegressionTest();
@@ -9281,6 +9282,22 @@ void tst_qqmlecmascript::gcCrashRegressionTest()
QCOMPARE(process.exitCode(), 0);
}
+void tst_qqmlecmascript::bindingOnQProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("bindingOnQProperty.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> test(component.create());
+ test->setProperty("externalValue", 42);
+ QCOMPARE(test->property("value").toInt(), 42);
+ test->setProperty("externalValue", 100);
+ QCOMPARE(test->property("value").toInt(), 100);
+
+ QVERIFY(qobject_cast<ClassWithQProperty*>(test.data()));
+ QProperty<int> &qprop = static_cast<ClassWithQProperty*>(test.data())->value;
+ QVERIFY(qprop.hasBinding());
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"