diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-27 12:11:18 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-27 13:55:22 +0200 |
commit | fc9199e4dbce55b011f66c36391e6c6aa08bd318 (patch) | |
tree | 990b1bad59f9c46163bee2ca6ee3313ebecb31de | |
parent | c317b2e46527b14c8fd30e0d198a9ee134cee123 (diff) |
Improve reliability of propertyVarOwnership test
In the last expect-to-collect-a-QObject test, avoid calling gc() from within
JavaScript and call it from C++ instead with zap stacking. That reduces the
probability of finding an old reference on the stack that would keep the
object alive.
Change-Id: Ia9c66dd188f31264a70ad4dbd20356d16aa7a057
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml index c2325fb5ee..580b95e51d 100644 --- a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.5.qml @@ -21,8 +21,6 @@ Item { } 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. test = !(SingletonType.QObject.trackedObjectProperty("varprop")); // deferences varProperties of object. diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 166e6cb83d..5d02f7985b 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -320,14 +320,20 @@ static void NO_INLINE zapSomeStack() memset(buf, 0, 4096); } -static void gc(QQmlEngine &engine) +static void gcWithoutDeferredObjectDeletion(QQmlEngine &engine) { zapSomeStack(); engine.collectGarbage(); +} + +static void gc(QQmlEngine &engine) +{ + gcWithoutDeferredObjectDeletion(engine); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); } + void tst_qqmlecmascript::initTestCase() { QQmlDataTest::initTestCase(); @@ -4753,6 +4759,8 @@ void tst_qqmlecmascript::propertyVarOwnership() QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.5.qml")); QObject *object = component.create(); QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "createComponent"); + gcWithoutDeferredObjectDeletion(engine); QMetaObject::invokeMethod(object, "runTest"); QCOMPARE(object->property("test").toBool(), true); delete object; |