aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-03-08 16:18:15 +0100
committerLars Knoll <lars.knoll@qt.io>2018-03-08 16:24:59 +0000
commitf514451cc2e3610e160b5dc8ccd1e390730ecc67 (patch)
treeb02d6e0de35fde62f6ce7864d5053df01d4f495e /src/qml/qml
parent4838687eaa63de6e4d6821f14cf865a13af9ebc1 (diff)
Fix unnecessary evaluation of dependent bindings
Given two simple bindings in this order property int firstVar: secondVar property int secondVar: ... then the binding expression for "secondVar" ends up being evaluated twice at run-time. The first time happens when enabling the binding expression for "firstVar", which results in the engine detecting that there is a dependency onto another binding that has not been enabled yet. This is when QQmlData::flushPendingBinding(Impl) enables the expression for secondVar and does an initial evaluation. Afterwards the QQmlObjectCreator continues enabling the next binding in ::finalize(), which will end up evaluating secondVar a second time, unnecessarily. We can detect this case inside setEnabled and only call update() if we transition from disabled to enabled state. This should also cover the case of bindings created and assigned dynamically through QtQuick PropertyChanges / States, as those call setEnabled(false) before removing the binding (to replace it with something else) and setEnabled(true) when reverting the state (in QQmlPropertyPrivate::setBinding). Change-Id: I447432891eabff2c4393f5abfee1092992746fa0 Task-number: QTBUG-66945 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlbinding.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index ca3bff43a4..bc7fccb2c0 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -490,6 +490,7 @@ void QQmlBinding::refresh()
void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags)
{
+ const bool wasEnabled = enabledFlag();
setEnabledFlag(e);
setNotifyOnValueChanged(e);
@@ -499,7 +500,7 @@ void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags)
m_nextBinding.clearFlag2();
}
- if (e)
+ if (e && !wasEnabled)
update(flags);
}