diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-06-11 10:23:07 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-06-12 06:33:21 +0200 |
| commit | 5137c85f1b187a9110976c2f7f807a18cea073e6 (patch) | |
| tree | cbb4bf9d6705d77910d5c4ca6cd77bcc6c3009bc /src/qml/jsruntime/qv4engine.cpp | |
| parent | a4ef8ef8f74241a95f17c6a0e478468ee70eebd4 (diff) | |
QtQml: Do not crash when registering native modules on QQmlEngine
We need to tell the type loader that this is an ECMAScript module since
it cannot determine it from the file name.
Amends commit dc60c305a20d518012d4f034c4fa2a7395ebf31f
Pick-to: 6.10 6.9 6.8
Change-Id: Ie91bce86a08a81ff3df6c11d016308e3e380f15f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 4bb9baea90..684c36a094 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -2195,8 +2195,9 @@ ExecutionEngine::Module ExecutionEngine::registerNativeModule( QQmlRefPointer<CompiledData::CompilationUnit> cu; if (m_qmlEngine) { - // Make sure the type loader doesn't try to resolve the script anymore. - cu = QQmlEnginePrivate::get(m_qmlEngine)->typeLoader.injectScript(url, 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 = QQmlEnginePrivate::get(m_qmlEngine)->typeLoader.injectModule(url, unit); } else { cu = QQml::makeRefPointer<CompiledData::CompilationUnit>(unit); } |
