From 53085399f56714db27cbdebe554146528d13c94e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 7 Jun 2011 16:34:04 +1000 Subject: Dispose of WorkerScripts in correct Isolate We were disposing them in the main thread isolate which caused corruption of the v8 heap. Specifically this showed in asserting allocations of persistent handles. --- .../qdeclarativeworkerscript/data/stressDispose.js | 6 ++++++ .../qdeclarativeworkerscript/data/stressDispose.qml | 13 +++++++++++++ .../tst_qdeclarativeworkerscript.cpp | 13 +++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js create mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml (limited to 'tests/auto/declarative/qdeclarativeworkerscript') diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js new file mode 100644 index 0000000000..5c4c5ec906 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js @@ -0,0 +1,6 @@ +WorkerScript.onMessage = function() { +} +for (var ii = 0; ii < 100; ++ii) { + var a = "HELLO WORLD"; +} + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml new file mode 100644 index 0000000000..d05918a074 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml @@ -0,0 +1,13 @@ +import QtQuick 1.0 + +Item { + WorkerScript { + id: worker + source: "stressDispose.js" + } + + Component.onCompleted: { + worker.sendMessage(10); + } +} + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index dd99a18ce3..2c85040f5f 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -80,6 +80,7 @@ private slots: void script_included(); void scriptError_onLoad(); void scriptError_onCall(); + void stressDispose(); private: void waitForEchoMessage(QDeclarativeWorkerScript *worker) { @@ -283,6 +284,18 @@ void tst_QDeclarativeWorkerScript::scriptError_onCall() delete worker; } +// Rapidly create and destroy worker scripts to test resources are being disposed +// in the correct isolate +void tst_QDeclarativeWorkerScript::stressDispose() +{ + for (int ii = 0; ii < 100; ++ii) { + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, SRCDIR "/data/stressDispose.qml"); + QObject *o = component.create(); + QVERIFY(o); + delete o; + } +} QTEST_MAIN(tst_QDeclarativeWorkerScript) -- cgit v1.2.3