[Regression] Fix lazy binding evaluation
authorSimon Hausmann <simon.hausmann@digia.com>
Tue, 28 Jan 2014 13:04:58 +0000 (14:04 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 6 Feb 2014 12:53:31 +0000 (13:53 +0100)
commit5dc7649f5ad7dca6e13707e827d001c3f118a6ef
tree48114fddc9f58ccde11185d5b3cdf2343b57ab33
parent44b16b06983ac3661f485ccfb3ffe88ba586d557
[Regression] Fix lazy binding evaluation

Commit 04774bb14c81688f86a2b31b8624bde8ebf59062 long time ago introduced the
concept of fixed order binding initialization with lazy evaluation, where a bit
is reserved for each binding that indicates whether it's been initialized the
first time or not. When reading a property on a QObject, we'd check if the
corresponding binding for the property has been initialized or not and flush
(i.e. execute) the binding if necessary.

As part of the V4/V8 clean-up, commit 1eb41200948ab414f1c47d93123b41c547a993df
removed the StoreV8Binding instruction, which made the call for setting the
this-binding-is-not-evaluated-yet bit. Nowadays we only use StoreBinding, for
which this optimization was never implemented (and not needed really). Now that
we have a unified JS code path, we need to set the pending binding bit and also
make sure that we call flushPendingBinding for any JS side property access
(accelerated or not).

Also flushPendingBindingImpl had two bugs:

   * In an attempt of trying to find the binding to flush, it could happen that
     we'd try to flush a previously destroyed binding (m_mePtr is null), so
     the b variable would remain the first binding in the object and we'd flush
     the wrong one (instead of none). Added a missing check to verify that the
     property index matches.
   * Also resetting the mePtr must be done through clear(), to ensure that the
     pointer in bindValues in the VME is also cleared, to avoid re-enabling the
     same binding again in complete();

Task-number: QTBUG-36441

Change-Id: Icdb0c8fb036051fd5d6c4d33b10cd0c0ed9a9d5c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmlvme.cpp
tests/auto/qml/qqmlecmascript/data/LazyBindingComponent.qml [new file with mode: 0644]
tests/auto/qml/qqmlecmascript/data/lazyBindingEvaluation.qml [new file with mode: 0644]
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp