diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-12-19 11:14:27 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-02-02 09:37:40 +0000 |
commit | 65606ea1559572d66ee8bfac77e87f3e8f447c3e (patch) | |
tree | ac129f9b750303c553bcf2021798ccdb9c24c48c /src/qml/types/qquickworkerscript.cpp | |
parent | 4939f4dd65ea28268656682ffa1378a9697fe5ac (diff) |
Remove double indirection between QJSEngine and QV4::ExecutionEngine
As QJSEngine's handle() method is internal, we can redefine it to return
a pointer to an ExecutionEngine. That makes many things easier.
Change-Id: Ie3df99e0bad5f00ad4fe73182896cd135fa82994
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/types/qquickworkerscript.cpp')
-rw-r--r-- | src/qml/types/qquickworkerscript.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 231c0fa810..32c0c86ff6 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -201,7 +201,7 @@ private: }; QQuickWorkerScriptEnginePrivate::WorkerEngine::WorkerEngine(QQuickWorkerScriptEnginePrivate *parent) -: QV8Engine(0), p(parent) + : QV8Engine(nullptr, new QV4::ExecutionEngine), p(parent) #if QT_CONFIG(qml_network) , accessManager(0) #endif @@ -214,6 +214,7 @@ QQuickWorkerScriptEnginePrivate::WorkerEngine::~WorkerEngine() #if QT_CONFIG(qml_network) delete accessManager; #endif + delete m_v4Engine; } void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() @@ -250,7 +251,7 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() QQuickWorkerScriptEnginePrivate::method_sendMessage)); QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = function; - *jsCallData->thisObject = global(); + *jsCallData->thisObject = m_v4Engine->global(); createsend.set(scope.engine, createsendconstructor->call(jsCallData)); } @@ -267,7 +268,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i QV4::ScopedValue v(scope); QV4::JSCallData jsCallData(scope, 1); jsCallData->args[0] = QV4::Primitive::fromInt32(id); - *jsCallData->thisObject = global(); + *jsCallData->thisObject = m_v4Engine->global(); v = f->call(jsCallData); if (scope.hasException()) v = scope.engine->catchException(); @@ -367,7 +368,7 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d Q_ASSERT(!!qmlContext); QV4::JSCallData jsCallData(scope, 2); - *jsCallData->thisObject = workerEngine->global(); + *jsCallData->thisObject = v4->global(); jsCallData->args[0] = qmlContext->d()->qml(); // ### jsCallData->args[1] = value; f->call(jsCallData); @@ -730,8 +731,7 @@ bool QQuickWorkerScript::event(QEvent *event) QQmlEngine *engine = qmlEngine(this); if (engine) { WorkerDataEvent *workerEvent = static_cast<WorkerDataEvent *>(event); - QV8Engine *v8engine = QQmlEnginePrivate::get(engine)->v8engine(); - QV4::Scope scope(QV8Engine::getV4(v8engine)); + QV4::Scope scope(engine->handle()); QV4::ScopedValue value(scope, QV4::Serialize::deserialize(workerEvent->data(), scope.engine)); emit message(QQmlV4Handle(value)); } |