From e8470c0b3a98fed5ad07e18d2a5e2f87270750ef Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 17 Nov 2023 09:35:35 +0100 Subject: [PATCH] QmlCompiler: When rejecting empty constants, don't crash afterwards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-119091 Change-Id: I1e24583aa998976c96bf3ddd6865f33cc4d5e94c Reviewed-by: Olivier De Cannière Reviewed-by: Fabian Kosmale (cherry picked from commit 8190f5bd68ff8acce33b2983e43f9bb5f9abec75) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 6049b22c97bb1d6ed4eeef97c81c189818ef5c78) --- src/qmlcompiler/qqmljscodegenerator.cpp | 1 + tests/auto/qml/qmlcppcodegen/data/failures.qml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp index 687bdbdb8f..e6723a25b6 100644 --- a/src/qmlcompiler/qqmljscodegenerator.cpp +++ b/src/qmlcompiler/qqmljscodegenerator.cpp @@ -448,6 +448,7 @@ void QQmlJSCodeGenerator::generate_MoveConst(int constIndex, int destTemp) input = toNumericString(v4Value.doubleValue()); } else { reject(u"unknown const type"_s); + return; } m_body += conversion(contained, changed, input) + u";\n"_s; generateOutputVariantConversion(contained); diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml index 35dd1f0255..22c0c8390a 100644 --- a/tests/auto/qml/qmlcppcodegen/data/failures.qml +++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml @@ -81,4 +81,6 @@ QtObject { readonly property int someNumber: 10 function writeToReadonly() { someNumber = 20 } + + property var silly: [,0] }