diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-12-08 09:26:36 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-12-08 09:46:04 +0100 |
commit | c3860cd04bbc089ef95bc441a1f8f1e46f9606f8 (patch) | |
tree | 03df7f03f2bceaf5129c2789d0440e66bc37ad2b /tests/auto/qml/qqmllistmodel | |
parent | 98c189d231535751670145fd7a3eed31ce8aa67d (diff) |
qqmlistmodel: Fix crash when modelCache is null
Fixes: QTBUG-89173
Pick-to: 5.15
Change-Id: Ife82518808fc5504ec42407e80ed3de89ed4adeb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllistmodel')
-rw-r--r-- | tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 3d0aaf1147..bdefc85770 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -131,6 +131,7 @@ private slots: void dynamic_roles_crash_QTBUG_38907(); void nestedListModelIteration(); void undefinedAppendShouldCauseError(); + void nullPropertyCrash(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1734,6 +1735,27 @@ void tst_qqmllistmodel::undefinedAppendShouldCauseError() QScopedPointer<QObject>(component.create()); } +// QTBUG-89173 +void tst_qqmllistmodel::nullPropertyCrash() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData( + R"(import QtQuick 2.15 + ListView { + model: ListModel { id: listModel } + + delegate: Item {} + + Component.onCompleted: { + listModel.append({"a": "value1", "b":[{"c":"value2"}]}) + listModel.append({"a": "value2", "b":[{"c":null}]}) + } + })", + QUrl()); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, "<Unknown File>: c is null. Adding an object with a null member does not create a role for it."); + QScopedPointer<QObject>(component.create()); +} QTEST_MAIN(tst_qqmllistmodel) |