diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-10 08:58:00 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-10 08:58:00 (GMT) |
commit | 9a05223ea9a6ee0dbaac256607be201ea08e6fb6 (patch) | |
tree | 54e5407758a18954bdaf64146b8d3ad8532b9297 /src/declarative/qml/qdeclarativeworkerscript.cpp | |
parent | ac27c8ad39a9646a9e509ba7a58f75eeae10bb6e (diff) | |
parent | bfc6a32c2a203766a6debdf19a265a4f0e198403 (diff) | |
download | Qt-9a05223ea9a6ee0dbaac256607be201ea08e6fb6.zip Qt-9a05223ea9a6ee0dbaac256607be201ea08e6fb6.tar.gz Qt-9a05223ea9a6ee0dbaac256607be201ea08e6fb6.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (119 commits)
Add Mac OS X bundle description for qml runtime
Cleanup
Disallow writes to read-only value type properties
Allow undefined to be assigned to QVariant properties
Add a Qt.isQtObject() method
Fix crash in QML library imports
Remove QT_VERSION checks in QML
List properties aren't read-only
Small doc fix.
Make sure WorkerScript thread is stopped on deletion. This also fixes
Release ListModel's worker agent on deletion.
Doc fixes
Fix example
Example code style improvements
Enable other wrapping modes.
TextEdit::wrap changed to TextEdit::wrapMode enumeration
Remove use of obsolete "Script" element.
unwarn
Replace "var" with "variant" in tests
Fix test after deletion of GraphicsObjectContainer.
...
Diffstat (limited to 'src/declarative/qml/qdeclarativeworkerscript.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeworkerscript.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index ddb0ece..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(); } @@ -508,7 +521,7 @@ void QDeclarativeWorkerScriptEngine::run() Here is an example: \qml - import Qt 4.6 + import Qt 4.7 Rectangle { width: 300 |