diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-08-29 14:09:55 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-09-06 13:06:05 +0000 |
commit | 77aefc95cf3fbae342004513fd8c9f3a0184eba9 (patch) | |
tree | 4310042298458dd94aac126d833f395ea227d00b /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | |
parent | 638f80c317a42d51ff312c077cc84f60538e5498 (diff) |
QQmlTableInstanceModel: don't fall back to use DelegateChooser as delegate
If the application uses a DelegateChooser, but the chooser fails to
resolve a delegate for a certain index, it should not use itself
as the delegate instead. This will cause the application to crash.
Instead, we just print a warning, and return nullptr, which will let
TableView handle the situation gracefully.
Change-Id: Ibaf9da09fd11149362f5b674fc61db47593de10c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 4ba36cd687..45b3566574 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -135,6 +135,7 @@ private slots: void checkRowAndColumnChangedButNotIndex(); void checkChangingModelFromDelegate(); void checkRebuildViewportOnly(); + void useDelegateChooserWithoutDefault(); }; tst_QQuickTableView::tst_QQuickTableView() @@ -1756,6 +1757,17 @@ void tst_QQuickTableView::checkRebuildViewportOnly() QCOMPARE(countAfterRebuild, itemCountBeforeRebuild); } +void tst_QQuickTableView::useDelegateChooserWithoutDefault() +{ + // Check that the application issues a warning (but doesn't e.g + // crash) if the delegate chooser doesn't cover all cells + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*failed")); + LOAD_TABLEVIEW("usechooserwithoutdefault.qml"); + auto model = TestModelAsVariant(2, 1); + tableView->setModel(model); + WAIT_UNTIL_POLISHED; +}; + QTEST_MAIN(tst_QQuickTableView) #include "tst_qquicktableview.moc" |