diff options
Diffstat (limited to 'tests/auto/qml/qqmlcomponent')
-rw-r--r-- | tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml b/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml index a62d81c844..4ca6b68cf8 100644 --- a/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml +++ b/tests/auto/qml/qqmlcomponent/data/onDestructionLookup.qml @@ -25,6 +25,5 @@ Item { Component.onCompleted: { createObject() - gc() } } diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 9eeff66e7a..408baeffee 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -96,6 +96,23 @@ public slots: } }; +// The JavaScriptCore GC marks the C stack. To try to ensure that there is +// no JSObject* left in stack memory by the compiler, we call this function +// to zap some bytes of memory before calling collectGarbage(). +static void zapSomeStack() +{ + char *buf = (char*)alloca(4096); + memset(buf, 0, 4096); +} + +static void gc(QQmlEngine &engine) +{ + zapSomeStack(); + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + class tst_qqmlcomponent : public QQmlDataTest { Q_OBJECT @@ -377,6 +394,7 @@ void tst_qqmlcomponent::onDestructionLookup() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("onDestructionLookup.qml")); QScopedPointer<QObject> object(component.create()); + gc(engine); QVERIFY(object != 0); QVERIFY(object->property("success").toBool()); } |