aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativeworkerscript.cpp
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2012-01-20 15:41:16 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-03 02:08:05 +0100
commitff8f1ac8caa86006a887d9104886aadd23f8750c (patch)
tree0b88914e086690d7f46e314a9bc4e7aca3c3ab67 /src/declarative/qml/qdeclarativeworkerscript.cpp
parent348b51327fe72fc8ea4292a3b5cb4df178c1d234 (diff)
Fix crash bug related to QDeclarativeListModel
If QDeclarativeListModel is deleted, all references to this object in QDeclarativeListModelWorkerAgent and WorkerScript objects should be removed and additional checking is needed when process the pending sync() events. Change-Id: I12b1f06699cc908e684af0886cf06d811c3fceb4 Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativeworkerscript.cpp')
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index b17c026e68..53283113b6 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -316,7 +316,6 @@ v8::Handle<v8::Object> QDeclarativeWorkerScriptEnginePrivate::getWorker(WorkerSc
bool QDeclarativeWorkerScriptEnginePrivate::event(QEvent *event)
{
- // XXX must handle remove request
if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event);
processMessage(workerEvent->workerId(), workerEvent->data());
@@ -328,6 +327,10 @@ bool QDeclarativeWorkerScriptEnginePrivate::event(QEvent *event)
} else if (event->type() == (QEvent::Type)WorkerDestroyEvent) {
emit stopThread();
return true;
+ } else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) {
+ WorkerRemoveEvent *workerEvent = static_cast<WorkerRemoveEvent *>(event);
+ workers.remove(workerEvent->workerId());
+ return true;
} else {
return QObject::event(event);
}
@@ -513,7 +516,11 @@ int QDeclarativeWorkerScriptEngine::registerWorkerScript(QDeclarativeWorkerScrip
void QDeclarativeWorkerScriptEngine::removeWorkerScript(int id)
{
- QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));
+ QDeclarativeWorkerScriptEnginePrivate::WorkerScript* script = d->workers.value(id);
+ if (script) {
+ script->owner = 0;
+ QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));
+ }
}
void QDeclarativeWorkerScriptEngine::executeUrl(int id, const QUrl &url)