aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript/qquickworkerscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlworkerscript/qquickworkerscript.cpp')
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index 635d508daf..20294d7ba7 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -548,6 +548,17 @@ void QQuickWorkerScript::setSource(const QUrl &source)
}
/*!
+ \qmlproperty bool WorkerScript::ready
+
+ This holds whether the WorkerScript has been initialized and is ready
+ for receiving messages via \tt WorkerScript.sendMessage().
+*/
+bool QQuickWorkerScript::ready() const
+{
+ return m_engine != nullptr;
+}
+
+/*!
\qmlmethod WorkerScript::sendMessage(jsobject message)
Sends the given \a message to a worker script handler in another
@@ -607,6 +618,8 @@ QQuickWorkerScriptEngine *QQuickWorkerScript::engine()
if (m_source.isValid())
m_engine->executeUrl(m_scriptId, m_source);
+ emit readyChanged();
+
return m_engine;
}
return nullptr;
@@ -623,8 +636,6 @@ void QQuickWorkerScript::componentComplete()
This signal is emitted when a message \a msg is received from a worker
script in another thread through a call to sendMessage().
-
- The corresponding handler is \c onMessage.
*/
bool QQuickWorkerScript::event(QEvent *event)