diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-30 05:32:43 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-30 05:32:43 (GMT) |
commit | 85db980578cb9f1b95be160a4386d9822c6ec6d0 (patch) | |
tree | 94db73d854dd559a355207f21aa49c903bcce28a /src/declarative/qml/qdeclarativeworkerscript.cpp | |
parent | 77cddec6ea642b073d1d9c017c865e740c0c60bc (diff) | |
download | Qt-85db980578cb9f1b95be160a4386d9822c6ec6d0.zip Qt-85db980578cb9f1b95be160a4386d9822c6ec6d0.tar.gz Qt-85db980578cb9f1b95be160a4386d9822c6ec6d0.tar.bz2 |
Make QDeclarativeParserStatus method pure virtual to encourage right code.
Fix all code to be right, except multimedia. Currently, it's not *required*
that types work without componentComplete, so not vital.
Diffstat (limited to 'src/declarative/qml/qdeclarativeworkerscript.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeworkerscript.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index 138d979..c55998f 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -538,7 +538,7 @@ void QDeclarativeWorkerScriptEngine::run() by the \tt onMessage() handler of \tt myWorker. */ QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent) -: QObject(parent), m_engine(0), m_scriptId(-1) +: QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true) { } @@ -565,7 +565,7 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source) m_source = source; - if (m_engine) + if (engine()) m_engine->executeUrl(m_scriptId, m_source); emit sourceChanged(); @@ -580,7 +580,7 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source) */ void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message) { - if (!m_engine) { + if (!engine()) { qWarning("QDeclarativeWorkerScript: Attempt to send message before WorkerScript establishment"); return; } @@ -588,13 +588,19 @@ void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message) m_engine->sendMessage(m_scriptId, QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(message)); } -void QDeclarativeWorkerScript::componentComplete() +void QDeclarativeWorkerScript::classBegin() { - if (!m_engine) { + m_componentComplete = false; +} + +QDeclarativeWorkerScriptEngine *QDeclarativeWorkerScript::engine() +{ + if (m_engine) return m_engine; + if (m_componentComplete) { QDeclarativeEngine *engine = qmlEngine(this); if (!engine) { - qWarning("QDeclarativeWorkerScript: componentComplete() called without qmlEngine() set"); - return; + qWarning("QDeclarativeWorkerScript: engine() called without qmlEngine() set"); + return 0; } m_engine = QDeclarativeEnginePrivate::get(engine)->getWorkerScriptEngine(); @@ -602,7 +608,16 @@ void QDeclarativeWorkerScript::componentComplete() if (m_source.isValid()) m_engine->executeUrl(m_scriptId, m_source); + + return m_engine; } + return 0; +} + +void QDeclarativeWorkerScript::componentComplete() +{ + m_componentComplete = true; + engine(); // Get it started now. } /*! |