summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-30 05:25:01 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-30 06:04:07 (GMT)
commit2661be1bacdd83d1b3e6207c519c2699edfdc1d0 (patch)
treef030a26c2e9641d0a16aa429ee07ad1b5ad7a490
parent859304f5a8d9169a3f2f30e013d460b0e93c118f (diff)
downloadQt-2661be1bacdd83d1b3e6207c519c2699edfdc1d0.zip
Qt-2661be1bacdd83d1b3e6207c519c2699edfdc1d0.tar.gz
Qt-2661be1bacdd83d1b3e6207c519c2699edfdc1d0.tar.bz2
WorkerScript was receiving events after deletion and trying to process
these events.
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp11
2 files changed, 9 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index a7ed358..628681f 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -437,8 +437,12 @@ QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngin
QDeclarativeWorkerScriptEngine::~QDeclarativeWorkerScriptEngine()
{
+ d->m_lock.lock();
qDeleteAll(d->workers);
- delete d; d = 0;
+ d->workers.clear();
+ d->m_lock.unlock();
+
+ d->deleteLater();
}
QDeclarativeWorkerScriptEnginePrivate::WorkerScript::WorkerScript()
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index fcb453c..12000d0 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -193,7 +193,7 @@ void tst_QDeclarativeListModel::dynamic_data()
QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
- QTest::newRow("clear2") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
+ QTest::newRow("clear3") << "{append({'foo':123});clear();get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range";
QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "";
QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "";
@@ -290,8 +290,6 @@ void tst_QDeclarativeListModel::dynamic_worker_data()
void tst_QDeclarativeListModel::dynamic_worker()
{
- QSKIP("", SkipAll);
-
QFETCH(QString, script);
QFETCH(int, result);
QFETCH(QString, warning);
@@ -324,6 +322,7 @@ void tst_QDeclarativeListModel::dynamic_worker()
// changes are reflected in the list model in the main thread
if (QByteArray(QTest::currentDataTag()).startsWith("nested"))
QTest::ignoreMessage(QtWarningMsg, "QML ListModel (unknown location) Cannot add nested list values when modifying or after modification from a worker script");
+
QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
waitForWorker(item);
@@ -342,7 +341,6 @@ void tst_QDeclarativeListModel::dynamic_worker()
void tst_QDeclarativeListModel::convertNestedToFlat_fail()
{
- QSKIP("", SkipAll);
// If a model has nested data, it cannot be used at all from a worker script
QFETCH(QString, script);
@@ -368,7 +366,7 @@ void tst_QDeclarativeListModel::convertNestedToFlat_fail()
delete item;
QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running");
- qApp->processEvents();
+ qApp->processEvents();
}
void tst_QDeclarativeListModel::convertNestedToFlat_fail_data()
@@ -387,7 +385,6 @@ void tst_QDeclarativeListModel::convertNestedToFlat_fail_data()
void tst_QDeclarativeListModel::convertNestedToFlat_ok()
{
- QSKIP("", SkipAll);
// If a model only has plain data, it can be modified from a worker script. However,
// once the model is used from a worker script, it no longer accepts nested data
@@ -429,7 +426,7 @@ void tst_QDeclarativeListModel::convertNestedToFlat_ok()
delete item;
QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running");
- qApp->processEvents();
+ qApp->processEvents();
}
void tst_QDeclarativeListModel::convertNestedToFlat_ok_data()