Fix qqmlecmascript::propertyVarOwnership
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 14:49:34 +0000 (16:49 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 15:50:39 +0000 (17:50 +0200)
Don't rely on o = new Date in the test-case to really clear the last "reference"
on the stack. As it turns out, in v4, we sometimes allocate the result of "new Date"
in a different slot and the old slot is still around (and thus the object is
visible and marked).

Instead work with separate scopes, which requires a little helper function in JS.

Change-Id: I5f318feaccfc7d83dbe28be043a0ee83e0c16355
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml

index 1143eaf..c2325fb 100644 (file)
@@ -5,7 +5,8 @@ Item {
     id: testOwnership
     property bool test: false
 
-    function runTest() {
+    function createComponent()
+    {
         var o;
         var c = Qt.createComponent("ComponentWithVarProp.qml");
         if (c.status == Component.Ready) {
@@ -15,8 +16,12 @@ Item {
         }
         o.varprop = true;                // causes initialization of varProperties.
         SingletonType.QObject.trackObject(o);        // stores QObject ptr
-        if (SingletonType.QObject.trackedObject() == null) return;        // is still valid, should have a valid v8object.
-        o = new Date();                  // causes object to be gc-able.
+        if (SingletonType.QObject.trackedObject() == null) return false // is still valid, should have a valid v8object.
+        return true;
+    }
+
+    function runTest() {
+        if (!createComponent()) return;
         gc();  // collect object's v8object + varProperties, queues deleteLater.
         if (SingletonType.QObject.trackedObject() != null) return;        // v8object was previously collected.
         SingletonType.QObject.setTrackedObjectProperty("varprop");        // deferences varProperties of object.