aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-08-26 16:11:38 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-08-30 13:48:19 +0000
commit12d8004874c3f69ddd5aa7622da309c46930336b (patch)
treee0bdbb130381ac35469494734c2793ddd153ab8e /tests/auto/qml/qqmlecmascript
parentbb26b8ea7b973cf53099a35028780309750b10c7 (diff)
Fix binding dependencies when used in together with functions
When a function called from a binding would access a scope or context property, we would end up registering those dependencies as permanent dependencies in the expression and set m_permanentDependenciesRegistered to true. Then after the binding evaluation itself, we would not end up registering the real binding's permanent dependencies. Change-Id: I3b6c1c181aa064d535362c736b5b2bbc4f576ba9 Done-with: Erik Task-number: QTBUG-54394 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dependenciesWithFunctions.qml12
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp13
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/dependenciesWithFunctions.qml b/tests/auto/qml/qqmlecmascript/data/dependenciesWithFunctions.qml
new file mode 100644
index 0000000000..57d3ae2f14
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/dependenciesWithFunctions.qml
@@ -0,0 +1,12 @@
+import QtQml 2.0
+QtObject {
+ property int value: 100
+ property bool success: {
+ unrelatedFunction();
+ return value == 42;
+ }
+ property int unrelatedValue: 100
+ function unrelatedFunction() {
+ return unrelatedValue;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index a5373ccbcd..c734a0a011 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -84,6 +84,7 @@ private slots:
void arrayExpressions();
void contextPropertiesTriggerReeval();
void objectPropertiesTriggerReeval();
+ void dependenciesWithFunctions();
void deferredProperties();
void deferredPropertiesErrors();
void deferredPropertiesInComponents();
@@ -881,6 +882,18 @@ void tst_qqmlecmascript::objectPropertiesTriggerReeval()
}
}
+void tst_qqmlecmascript::dependenciesWithFunctions()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("dependenciesWithFunctions.qml"));
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(object, qPrintable(component.errorString()));
+ QVERIFY(!object->property("success").toBool());
+ object->setProperty("value", 42);
+ QVERIFY(object->property("success").toBool());
+}
+
void tst_qqmlecmascript::deferredProperties()
{
QQmlComponent component(&engine, testFileUrl("deferredProperties.qml"));