diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-12-08 09:26:36 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-12-08 11:15:29 +0000 |
commit | 83100a84f2b0068b4cf725896bbb810415908334 (patch) | |
tree | 43f8ca3c5d1ece9f5978c6258df45cba847a2ec6 /tests | |
parent | 30c7a6c6a874264800d398df8c3ec65f30707c92 (diff) |
qqmlistmodel: Fix crash when modelCache is null
Fixes: QTBUG-89173
Change-Id: Ife82518808fc5504ec42407e80ed3de89ed4adeb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit c3860cd04bbc089ef95bc441a1f8f1e46f9606f8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-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 d54e3467b7..1953798a15 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -130,6 +130,7 @@ private slots: void dynamic_roles_crash_QTBUG_38907(); void nestedListModelIteration(); void undefinedAppendShouldCauseError(); + void nullPropertyCrash(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1723,6 +1724,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) |