aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-06-03 14:35:29 +0200
committerUlf Hermann <ulf.hermann@qt.io>2025-06-17 07:00:33 +0200
commitd2bc4a4330254c0c68a0ade51b59a71c4b67b470 (patch)
tree8345312f50df0be783618fd75a1d7e52c2ca65d7 /src/qml/jsruntime/qv4engine.cpp
parent8e0810c19c791386fd5f2cefc6b992f45be21750 (diff)
QtQml: Hold QQmlTypeLoader in QV4::ExecutionEngine
... rather than QQmlEngine. This paves the way for having the type loader attached to ExecutionEngine rather than QQmlEngine. Also, reference the execution engine in the type loader, in turn. Task-number: QTBUG-19407 Change-Id: I04e571c5c6ac5bce5e82537cb96c6940c7186f3a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 82e653a645..1f27ca1f1e 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -856,6 +856,10 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine)
ExecutionEngine::~ExecutionEngine()
{
+#if QT_CONFIG(qml_network)
+ delete networkAccessManager;
+#endif
+ m_typeLoader.reset();
qDeleteAll(m_extensionData);
delete m_multiplyWrappedQObjects;
m_multiplyWrappedQObjects = nullptr;
@@ -884,6 +888,15 @@ ExecutionEngine::~ExecutionEngine()
#endif
}
+#if QT_CONFIG(qml_network)
+QNetworkAccessManager *ExecutionEngine::getNetworkAccessManager()
+{
+ if (!networkAccessManager)
+ networkAccessManager = typeLoader()->createNetworkAccessManager(nullptr);
+ return networkAccessManager;
+}
+#endif
+
#if QT_CONFIG(qml_debug)
void ExecutionEngine::setDebugger(Debugging::Debugger *debugger)
{
@@ -2194,13 +2207,10 @@ ExecutionEngine::Module ExecutionEngine::registerNativeModule(
return Module();
QQmlRefPointer<CompiledData::CompilationUnit> cu;
- if (m_qmlEngine) {
- // Make sure the type loader doesn't try to resolve the module anymore.
- // If some other code requests that same module, we need to produce the same CU.
- cu = QQmlEnginePrivate::get(m_qmlEngine)->typeLoader.injectModule(url, unit);
- } else {
- cu = QQml::makeRefPointer<CompiledData::CompilationUnit>(unit);
- }
+
+ // Make sure the type loader doesn't try to resolve the module anymore.
+ // If some other code requests that same module, we need to produce the same CU.
+ cu = typeLoader()->injectModule(url, unit);
QQmlRefPointer<ExecutableCompilationUnit> newModule = insertCompilationUnit(std::move(cu));
@@ -2956,11 +2966,4 @@ int ExecutionEngine::registerExtension()
return registrationData()->extensionCount++;
}
-#if QT_CONFIG(qml_network)
-QNetworkAccessManager *QV4::detail::getNetworkAccessManager(ExecutionEngine *engine)
-{
- return engine->qmlEngine()->networkAccessManager();
-}
-#endif // qml_network
-
QT_END_NAMESPACE