From 7a344ef2b7796731a69a4f36e13ca9cf6f3b1ee9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 4 Dec 2013 16:30:54 +0100 Subject: Fix dependency calculation for context and scope properties We were incorrectly calculating writing to a context or scope property as a dependency for an expression. We don't know whether a property is being written only or also being read from at lookup time, but we can make that decision in the isel then when generating the move instructions. So initially context and scope properties end up in a candidate set first and get promoted to real dependencies when they're being used in reading moves. Task-number: QTBUG-35210 Change-Id: Ia67057abafc2d611e1e6605327b4965ebe91cbed Reviewed-by: Lars Knoll --- .../qqmlecmascript/data/noCaptureWhenWritingProperty.qml | 14 ++++++++++++++ tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml b/tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml new file mode 100644 index 0000000000..8b8601692d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/noCaptureWhenWritingProperty.qml @@ -0,0 +1,14 @@ +import QtQml 2.0 +QtObject { + property bool somePropertyEvaluated: false; + + property int someProperty: { + // It's sort of evil to set the property here, but that doesn't mean that + // this expression should get re-evaluated when unrelatedProperty changes later. + somePropertyEvaluated = true + return 20; + } + Component.onCompleted: { + somePropertyEvaluated = false + } +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 1e18e3c269..7b89709923 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -319,6 +319,7 @@ private slots: void stackLimits(); void idsAsLValues(); void qtbug_34792(); + void noCaptureWhenWritingProperty(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -7498,6 +7499,14 @@ void tst_qqmlecmascript::qtbug_34792() delete object; } +void tst_qqmlecmascript::noCaptureWhenWritingProperty() +{ + QQmlComponent component(&engine, testFileUrl("noCaptureWhenWritingProperty.qml")); + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("somePropertyEvaluated").toBool(), false); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3