diff options
author | Glenn Watson <glenn.watson@nokia.com> | 2012-03-09 09:19:35 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-09 09:56:25 +0100 |
commit | 88a6f771f203814e118f71196c800c93ee769055 (patch) | |
tree | 338a91956273422f8d4a2cf9513fc8a15c36d3a2 /tests/auto/qml/qquicklistmodel | |
parent | 2ecf1f5d8ae37bdb4624bd1e3888a65ec357f7b3 (diff) |
Fix crash in listmodel when data is assigned incorrectly.
If a listmodel with static role types is created, it would crash
if a role was assigned a value type such as string, and then
subsequently assigned an array (sub list) value from a dynamic
meta object (created when using get() from JS).
Change-Id: Ibfd0b0b40be13b04103b49462cfae42a5c9f9fb9
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qquicklistmodel')
-rw-r--r-- | tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp index 3fcce60bfb..69a8d2ecd8 100644 --- a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp +++ b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp @@ -139,6 +139,7 @@ private slots: void role_mode(); void dynamic_role(); void dynamic_role_data(); + void string_to_list_crash(); }; bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1627,6 +1628,19 @@ void tst_qquicklistmodel::dynamic_role() qApp->processEvents(); } +void tst_qquicklistmodel::string_to_list_crash() +{ + QQmlEngine engine; + QQuickListModel model; + QQmlEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextObject(&model); + QString script = QLatin1String("{append({'a':'data'});get(0).a = [{'x':123}]}"); + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Can't assign to existing role 'a' of different type [String -> List]"); + QQmlExpression e(engine.rootContext(), &model, script); + // Don't crash! + e.evaluate(); +} + QTEST_MAIN(tst_qquicklistmodel) #include "tst_qquicklistmodel.moc" |