diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-02-15 14:23:11 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-02-17 20:49:58 +0000 |
commit | b2c71d6518143b3d2a9bd3aef1d72ee5929891fc (patch) | |
tree | b386c7752998885f4318dd90d003237ff3de7e3e /src/qml/compiler/qqmlirbuilder.cpp | |
parent | 97d1db53394077b5e5c159f5eb14af5e3ddb9158 (diff) |
Fix "Expression depends on non-NOTIFYable properties" regression
CONSTANT properties are by nature non-NOTIFYable.
The issue behind the regression is caused by the fact that we were
capturing a property regardless of whether or not it was const.
There were two states that captureRequired was expressing:
true: We're reading the property of a QObject, and we're not quite sure
where the QObject comes from or what it is. So, when reading that
property at run-time, make sure that we capture where we read that
property so that if it changes we can re-evaluate the entire
expression.
false: We're reading the property of a QObject, and we know that it's
the scope object or context object, which we know very well. Instead of
registering a property capture every time, we can do that ahead of time
and then register all those captures in one shot in
registerQmlDependencies().
There is a third state that is only relevant when captureRequired is
false: We're reading a property from the scope or context object, but
it's a CONSTANT property, so we don't need to register a dependency
at all.
This patch adds replaces captureRequired with the PropertyCapturePolicy
enum, which accounts for the third state and, as a bonus, makes the
code easier to understand.
Task-number: QTBUG-66361
Change-Id: I6cef1deb76538fbdacf1324b4467403dd40dd7de
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 6de0ed6f7d..6c8ca4bbfc 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -2231,20 +2231,28 @@ QV4::Compiler::Codegen::Reference JSCodeGen::fallbackNameLookup(const QString &n QQmlPropertyData *data = lookupQmlCompliantProperty(_scopeObject, name); if (!data) return Reference::fromName(this, name); + Reference base = Reference::fromStackSlot(this, _qmlContextSlot); - bool captureRequired = !data->isConstant() && !data->isQmlBinding(); - return Reference::fromQmlScopeObject(base, data->coreIndex(), data->notifyIndex(), - captureRequired); + Reference::PropertyCapturePolicy capturePolicy; + if (!data->isConstant() && !data->isQmlBinding()) + capturePolicy = Reference::CaptureAtRuntime; + else + capturePolicy = data->isConstant() ? Reference::DontCapture : Reference::CaptureAheadOfTime; + return Reference::fromQmlScopeObject(base, data->coreIndex(), data->notifyIndex(), capturePolicy); } if (_contextObject) { QQmlPropertyData *data = lookupQmlCompliantProperty(_contextObject, name); if (!data) return Reference::fromName(this, name); + Reference base = Reference::fromStackSlot(this, _qmlContextSlot); - bool captureRequired = !data->isConstant() && !data->isQmlBinding(); - return Reference::fromQmlContextObject(base, data->coreIndex(), data->notifyIndex(), - captureRequired); + Reference::PropertyCapturePolicy capturePolicy; + if (!data->isConstant() && !data->isQmlBinding()) + capturePolicy = Reference::CaptureAtRuntime; + else + capturePolicy = data->isConstant() ? Reference::DontCapture : Reference::CaptureAheadOfTime; + return Reference::fromQmlContextObject(base, data->coreIndex(), data->notifyIndex(), capturePolicy); } if (m_globalNames.contains(name)) { |