summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-09 05:59:31 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-09 05:59:31 (GMT)
commit75581e3330916f756462ff6924abf2c62c0d228e (patch)
tree5df732f65ba220fafac5b772229e3101d783f46d /src
parent4a40a67827c8f259876e906a5a9afd2159ca9028 (diff)
parent79832f2156745ee2c6608ce7425fb2350b56f18d (diff)
downloadQt-75581e3330916f756462ff6924abf2c62c0d228e.zip
Qt-75581e3330916f756462ff6924abf2c62c0d228e.tar.gz
Qt-75581e3330916f756462ff6924abf2c62c0d228e.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp13
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp3
-rw-r--r--src/declarative/util/qdeclarativelistmodelworkeragent_p.h1
3 files changed, 16 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index caf680e..9e137b5 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -107,6 +107,10 @@ class QDeclarativeWorkerScriptEnginePrivate : public QObject
{
Q_OBJECT
public:
+ enum WorkerEventTypes {
+ WorkerDestroyEvent = QEvent::User + 100
+ };
+
QDeclarativeWorkerScriptEnginePrivate(QDeclarativeEngine *eng);
struct ScriptEngine : public QDeclarativeScriptEngine
@@ -159,6 +163,9 @@ public:
static QScriptValue onMessage(QScriptContext *ctxt, QScriptEngine *engine);
static QScriptValue sendMessage(QScriptContext *ctxt, QScriptEngine *engine);
+signals:
+ void stopThread();
+
protected:
virtual bool event(QEvent *);
@@ -246,6 +253,9 @@ bool QDeclarativeWorkerScriptEnginePrivate::event(QEvent *event)
WorkerLoadEvent *workerEvent = static_cast<WorkerLoadEvent *>(event);
processLoad(workerEvent->workerId(), workerEvent->url());
return true;
+ } else if (event->type() == (QEvent::Type)WorkerDestroyEvent) {
+ emit stopThread();
+ return true;
} else {
return QObject::event(event);
}
@@ -429,6 +439,7 @@ QDeclarativeWorkerScriptEngine::QDeclarativeWorkerScriptEngine(QDeclarativeEngin
: QThread(parent), d(new QDeclarativeWorkerScriptEnginePrivate(parent))
{
d->m_lock.lock();
+ connect(d, SIGNAL(stopThread()), this, SLOT(quit()), Qt::DirectConnection);
start(QThread::LowPriority);
d->m_wait.wait(&d->m_lock);
d->moveToThread(this);
@@ -440,8 +451,10 @@ QDeclarativeWorkerScriptEngine::~QDeclarativeWorkerScriptEngine()
d->m_lock.lock();
qDeleteAll(d->workers);
d->workers.clear();
+ QCoreApplication::postEvent(d, new QEvent((QEvent::Type)QDeclarativeWorkerScriptEnginePrivate::WorkerDestroyEvent));
d->m_lock.unlock();
+ wait();
d->deleteLater();
}
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 28bd852..37bbb14 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -264,6 +264,9 @@ QDeclarativeListModel::QDeclarativeListModel(bool workerCopy, QObject *parent)
QDeclarativeListModel::~QDeclarativeListModel()
{
+ if (m_agent)
+ m_agent->release();
+
delete m_nested;
delete m_flat;
}
diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h
index b6a643b..53d30c2 100644
--- a/src/declarative/util/qdeclarativelistmodelworkeragent_p.h
+++ b/src/declarative/util/qdeclarativelistmodelworkeragent_p.h
@@ -66,7 +66,6 @@ QT_MODULE(Declarative)
class QDeclarativeListModel;
-// Currently this will leak as no-one releases it in the worker thread
class QDeclarativeListModelWorkerAgent : public QObject
{
Q_OBJECT