aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript/qquickworkerscript.cpp
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2019-12-06 10:56:22 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-12-06 14:32:16 +0000
commit3c4247e1e021b6bcc480afc0716e0231575d0501 (patch)
tree8f1f72b91e150b88e53e5b4ccac6a551e096220b /src/qmlworkerscript/qquickworkerscript.cpp
parent8fadf5d374936e50b8bce5adb1f10da2f66eac2b (diff)
src/qmlworkerscript: Add ready property to WorkerScript
Previously it was impossible to determine whether a WorkerScript has been fully initialized. This commit introduces a ready property that allows outside Components to determine whether it is safe to send signals. Fixes: QTBUG-80413 Change-Id: I2a1892b5e759e317de791e71d79fbb0cbd320dd3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlworkerscript/qquickworkerscript.cpp')
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index 8b236697b9..9e4b3e1b46 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -533,6 +533,17 @@ void QQuickWorkerScript::setSource(const QUrl &source)
}
/*!
+ \qmlproperty url 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
@@ -592,6 +603,8 @@ QQuickWorkerScriptEngine *QQuickWorkerScript::engine()
if (m_source.isValid())
m_engine->executeUrl(m_scriptId, m_source);
+ emit readyChanged();
+
return m_engine;
}
return nullptr;