From 6371b208a9e55845090dcd34234e314c6587c105 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 17 May 2016 15:18:12 +0200 Subject: Revert "Remove this piece of code" This reverts commit bad007360a0f6fba304d8f4c99826a1250fd886c. The lookup in the global object is necessary to detect whether we've seen any unresolved properties. This is used for the optimization of skipping binding refresh updates when a context property changes. Task-number: QTBUG-53431 Change-Id: Idb39a32e4b58b915496bbb9d8a098dc17a6f688a Reviewed-by: Lars Knoll --- tests/auto/qml/qqmlcontext/data/qtbug_53431.qml | 7 +++++++ tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/auto/qml/qqmlcontext/data/qtbug_53431.qml (limited to 'tests/auto/qml/qqmlcontext') diff --git a/tests/auto/qml/qqmlcontext/data/qtbug_53431.qml b/tests/auto/qml/qqmlcontext/data/qtbug_53431.qml new file mode 100644 index 0000000000..2ceee2bade --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/qtbug_53431.qml @@ -0,0 +1,7 @@ +import QtQml 2.0 +QtObject { + property int value: { + console.log("lookup in global object") + return 1 + } +} diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index 18ef7ac31d..d338e6f5ad 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -61,6 +61,7 @@ private slots: void refreshExpressions(); void refreshExpressionsCrash(); void refreshExpressionsRootContext(); + void skipExpressionRefresh_qtbug_53431(); void qtbug_22535(); void evalAfterInvalidate(); @@ -642,6 +643,19 @@ void tst_qqmlcontext::refreshExpressionsRootContext() delete o1; } +void tst_qqmlcontext::skipExpressionRefresh_qtbug_53431() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("qtbug_53431.qml")); + QScopedPointer object(component.create(0)); + QVERIFY(!object.isNull()); + QCOMPARE(object->property("value").toInt(), 1); + object->setProperty("value", 10); + QCOMPARE(object->property("value").toInt(), 10); + engine.rootContext()->setContextProperty("randomContextProperty", 42); + QCOMPARE(object->property("value").toInt(), 10); +} + void tst_qqmlcontext::qtbug_22535() { QQmlEngine engine; -- cgit v1.2.3