Revert "Do not execute overwritten bindings"
authorAaron Kennedy <aaron.kennedy@nokia.com>
Wed, 4 Apr 2012 11:19:06 +0000 (12:19 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 4 Apr 2012 11:29:13 +0000 (13:29 +0200)
This reverts commit 639208cc7f3ab3d8356363559e8fcf168e32cf0b.

There were two problems with this submit:
    1. Maintaining a hash of all the properties we have assigned bindings
       to is massively inefficient.
    2. The autotest was in the qquickbinding testcase which is for the
       QtQuick "Binding" element, not for generic binding tests.

Change-Id: Id2150dbfe86c6844cc0b115d7f941ae8d6a60643
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
src/qml/qml/qqmlvme.cpp
tests/auto/qml/qquickbinding/data/InnerObject.qml [deleted file]
tests/auto/qml/qquickbinding/data/OuterObject.qml [deleted file]
tests/auto/qml/qquickbinding/data/replaceBinding.qml [deleted file]
tests/auto/qml/qquickbinding/tst_qquickbinding.cpp

index 5534583..f5a6954 100644 (file)
 #include <QtCore/qvarlengtharray.h>
 #include <QtQml/qjsvalue.h>
 
-#include <utility>
-
 QT_BEGIN_NAMESPACE
 
-template <typename T1, typename T2>
-uint qHash(const std::pair<T1, T2> &p)
-{
-    return qHash(p.first) ^ qHash(p.second);
-}
-
 using namespace QQmlVMETypes;
 
 #define VME_EXCEPTION(desc, line) \
@@ -1224,40 +1216,18 @@ QQmlContextData *QQmlVME::complete(const Interrupt &interrupt)
     {
     QQmlTrace trace("VME Binding Enable");
     trace.event("begin binding eval");
+    while (!bindValues.isEmpty()) {
+        QQmlAbstractBinding *b = bindValues.pop();
 
-    size_t bindValuesRemaining = bindValues.count();
-    if (bindValuesRemaining > 0) {
-        typedef std::pair<QObject *, int> TargetProperty;
-
-        QSet<TargetProperty> boundProperties;
-        boundProperties.reserve(bindValuesRemaining - 1);
-
-        while (bindValuesRemaining > 0) {
-            QQmlAbstractBinding *b = bindValues.pop();
-            --bindValuesRemaining;
-
-            if (b) {
-                b->m_mePtr = 0;
-
-                TargetProperty property(std::make_pair(b->object(), b->propertyIndex()));
-                if (!boundProperties.contains(property)) {
-                    // We have not assigned a binding to this property yet
-                    b->setEnabled(true, QQmlPropertyPrivate::BypassInterceptor |
-                                        QQmlPropertyPrivate::DontRemoveBinding);
-
-                    if (bindValuesRemaining > 0) {
-                        boundProperties.insert(property);
-                    }
-                } else {
-                    b->destroy();
-                }
-            }
-
-            if (watcher.hasRecursed() || interrupt.shouldInterrupt())
-                return 0;
+        if (b) {
+            b->m_mePtr = 0;
+            b->setEnabled(true, QQmlPropertyPrivate::BypassInterceptor |
+                                QQmlPropertyPrivate::DontRemoveBinding);
         }
-    }
 
+        if (watcher.hasRecursed() || interrupt.shouldInterrupt())
+            return 0;
+    }
     bindValues.deallocate();
     }
 
diff --git a/tests/auto/qml/qquickbinding/data/InnerObject.qml b/tests/auto/qml/qquickbinding/data/InnerObject.qml
deleted file mode 100644 (file)
index a8ed959..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 2.0
-
-QtObject {
-    property int foo1: 100
-    property int foo2: 100
-    property int foo3: { return 100; }
-    property int foo4: { return 100; }
-
-    property string bar1: 'Hello'
-    property string bar2: 'Hello'
-    property string bar3: { return 'Hello'; }
-    property string bar4: { return 'Hello'; }
-}
diff --git a/tests/auto/qml/qquickbinding/data/OuterObject.qml b/tests/auto/qml/qquickbinding/data/OuterObject.qml
deleted file mode 100644 (file)
index da571a9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQuick 2.0
-
-Item {
-    property InnerObject inner: InnerObject {}
-}
diff --git a/tests/auto/qml/qquickbinding/data/replaceBinding.qml b/tests/auto/qml/qquickbinding/data/replaceBinding.qml
deleted file mode 100644 (file)
index 670231a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 2.0
-
-OuterObject {
-    property bool success: false
-
-    inner.foo1: 200
-    inner.foo2: { return 200; }
-    inner.foo3: 200
-    inner.foo4: { return 200; }
-
-    inner.bar1: 'Goodbye'
-    inner.bar2: { return 'Goodbye' }
-    inner.bar3: 'Goodbye'
-    inner.bar4: { return 'Goodbye' }
-
-    Component.onCompleted: {
-        success = (inner.foo1 == 200 &&
-                   inner.foo2 == 200 &&
-                   inner.foo3 == 200 &&
-                   inner.foo4 == 200 &&
-                   inner.bar1 == 'Goodbye' &&
-                   inner.bar2 == 'Goodbye' &&
-                   inner.bar3 == 'Goodbye' &&
-                   inner.bar4 == 'Goodbye');
-    }
-}
index 0aef837..939c4a9 100644 (file)
@@ -57,7 +57,6 @@ private slots:
     void restoreBinding();
     void restoreBindingWithLoop();
     void deletedObject();
-    void replaceBinding();
 
 private:
     QQmlEngine engine;
@@ -193,17 +192,6 @@ void tst_qquickbinding::deletedObject()
     delete rect;
 }
 
-void tst_qquickbinding::replaceBinding()
-{
-    QQmlEngine engine;
-    QQmlComponent c(&engine, testFileUrl("replaceBinding.qml"));
-    QObject *obj = c.create();
-    QVERIFY(obj != 0);
-
-    QVERIFY(obj->property("success").toBool());
-    delete obj;
-}
-
 QTEST_MAIN(tst_qquickbinding)
 
 #include "tst_qquickbinding.moc"