diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-08-12 11:55:53 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-12 13:29:27 +0200 |
commit | 42dc821dd68cc63aa8300f2678639dbaacda1057 (patch) | |
tree | 4934e5f63f12e40aa750736cdb9eaa88127771af /tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | |
parent | 57a70efe4c54bbfc8109933503c45cc43127c6ad (diff) |
Improve reliability of tst_qqmlcomponent::onDestructionLookup auto test on Windows
The test relies on exact garbage collection, which we can't offer anymore.
But we can use the same tricks as in qqmlecmascript to improve the changes
of a successful collect significantly.
Change-Id: I7b3d7eca7a9bdb551a01a5a3da80549196c45f23
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp')
-rw-r--r-- | tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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()); } |