From ae8fb3800ac880bfa9805f9163709d96b66b7788 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 14 Jan 2021 11:42:20 +0100 Subject: QQmlComponent: Avoid crash when setting initial properties in JS module In a JS module, we lack a qml context. Thus, we have to check whether qmlContext is null. In that case we use the engine's scriptContext('s ExecutionContext) instead. Fixes: QTBUG-90245 Change-Id: I337e9c7cade472f52fc81c93d1152ff59f8018a5 Reviewed-by: Ulf Hermann (cherry picked from commit e68b498424f63c1cb6151e4fc6bbc50bac584909) --- src/qml/qml/qqmlcomponent.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 279befb351..f35c3011d3 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1369,7 +1369,8 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV if (engine->hasException) return; - QV4::ScopedStackFrame frame(scope, qmlContext->d()); + // js modules (mjs) have no qmlContext + QV4::ScopedStackFrame frame(scope, qmlContext ? qmlContext->d() : engine->scriptContext()->d()); while (1) { name = it.nextPropertyNameAsString(val); -- cgit v1.2.3