aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2024-01-03 17:34:59 +0100
committerOlivier De Cannière <olivier.decanniere@qt.io>2024-01-08 09:27:00 +0100
commit796dd2ab8c7b0e85f2469df9b79f65ca62719c8b (patch)
treedfe755a3fab13e5e00f930e0d37caffd86be42c1 /src/qml/compiler/qv4codegen.cpp
parenta707edb0ff66c9ec619dfedab5649d18eaf7abb8 (diff)
qv4codegen: Do not call functions on null objects inside optional chains
Amends: 86c48761dc7ba5bcac7dc6740e94efbfb8678403 Fixes: QTBUG-120504 Pick-to: 6.7 Change-Id: Id77236a07d7c1a16e2f60238909eff245c5c354a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 12639cba37..580406db86 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2001,7 +2001,7 @@ bool Codegen::visit(CallExpression *ast)
int thisObject = bytecodeGenerator->newRegister();
int functionObject = bytecodeGenerator->newRegister();
- if (ast->isOptional) {
+ if (ast->isOptional || m_optionalChainsStates.top().actuallyHasOptionals) {
base.loadInAccumulator();
bytecodeGenerator->addInstruction(Instruction::CmpEqNull());
auto jumpToUndefined = bytecodeGenerator->jumpTrue();