-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.2.4
The QML WorkerScript type will always reuse one thread, namely the QQmlEnginePrivate::workerScriptEngine thread (from the main/gui thread), no matter how many times the type is instantiated. This seems to be by design, though I don't really understand why. Now, either the design is wrong after all, or the documentation needs to be updated to clearly state that. From reading the documentation at least I got the impression that there's one thread per WorkerScript instance.
Here is a very quick and dirty hack that provides the behavior that I would expect:
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -623,10 +623,7 @@ QQuickWorkerScriptEngine *QQuickWorkerScript::engine()
return nullptr;
}
- QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine);
- if (enginePrivate->workerScriptEngine == nullptr)
- enginePrivate->workerScriptEngine = new QQuickWorkerScriptEngine(engine);
- m_engine = qobject_cast<QQuickWorkerScriptEngine *>(enginePrivate->workerScriptEngine);
+ m_engine = new QQuickWorkerScriptEngine(engine);
Q_ASSERT(m_engine);
m_scriptId = m_engine->registerWorkerScript(this);
| For Gerrit Dashboard: QTBUG-102025 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 405968,1 | WIP: Investigate impact of 1 thread (QQWSEngine) per WorkerScript | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |