diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-11-16 16:22:38 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-11-17 15:28:57 +0100 |
commit | 096f3c3097cb2f60c2f44d4d8c734fc33ffd0a3e (patch) | |
tree | c68b6ac957f904b9593b551d090ea54ccddc7a0c /tests/auto/qml | |
parent | fa09df7e1ab43a7ca4f81076c518d8530eea711d (diff) |
QmlCompiler: Don't access unavailable input accumulator on 'as'
We only read it if the target type is composite. Therefore, check for
composite first, before looking for the accumulator.
Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-119122
Change-Id: I2a50214f76ee4ffe2f877dc690704e7475b8bd77
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/asCast.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/asCast.qml b/tests/auto/qml/qmlcppcodegen/data/asCast.qml index 1befc08d0a..cb8155ca6c 100644 --- a/tests/auto/qml/qmlcppcodegen/data/asCast.qml +++ b/tests/auto/qml/qmlcppcodegen/data/asCast.qml @@ -28,4 +28,14 @@ Item { property QtObject dummyAsItem: dummy as Item property QtObject dummyAsRectangle: dummy as Rectangle property QtObject dummyAsDummy: dummy as Dummy + + property QtObject nullAsObject: null as QtObject + property QtObject nullAsItem: null as Item + property QtObject nullAsRectangle: null as Rectangle + property QtObject nullAsDummy: null as Dummy + + property QtObject undefinedAsObject: undefined as QtObject + property QtObject undefinedAsItem: undefined as Item + property QtObject undefinedAsRectangle: undefined as Rectangle + property QtObject undefinedAsDummy: undefined as Dummy } diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 37f874ba91..5d44b84475 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -657,6 +657,16 @@ void tst_QmlCppCodegen::asCast() QCOMPARE(qvariant_cast<QObject *>(root->property("dummyAsItem")), dummy); QCOMPARE(qvariant_cast<QObject *>(root->property("dummyAsRectangle")), nullptr); QCOMPARE(qvariant_cast<QObject *>(root->property("dummyAsDummy")), dummy); + + QCOMPARE(qvariant_cast<QObject *>(root->property("nullAsObject")), nullptr); + QCOMPARE(qvariant_cast<QObject *>(root->property("nullAsItem")), nullptr); + QCOMPARE(qvariant_cast<QObject *>(root->property("nullAsRectangle")), nullptr); + QCOMPARE(qvariant_cast<QObject *>(root->property("nullAsDummy")), nullptr); + + QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsObject")), nullptr); + QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsItem")), nullptr); + QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsRectangle")), nullptr); + QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsDummy")), nullptr); } void tst_QmlCppCodegen::attachedBaseEnum() |