diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2023-04-17 10:21:25 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2023-04-18 18:50:02 +0200 |
commit | fd489252a7c904c70afa299528b164d17e628dd8 (patch) | |
tree | 82c6b8ba921578820a7c62019476f0af3e0e2fed /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | |
parent | 838b9ee9fe3ad26e5b1fac1616cb575288f4f8a1 (diff) |
TableInstanceModel: handle roleName invalidation
roleNames are generally guaranteed to be stable (given that QAIM has no
change signal for them), except that resetting the model is allowed to
invalidate them. TableInstanceModel did so far not take this into account.
Handle this case correctly by snapshotting the current roleNames before
the model is reset. Afterwards, if we detect that roleNames has changed,
we throw the current model set up away and rebuild everything from
scratch – it is unlikely that a more efficient implementation would be
worth it.
Fixes: QTBUG-111987
Pick-to: 6.5 6.2
Change-Id: Id1e3b8e4f983c0f00fc7b30bd4897f1f7fcc3792
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 1869539c36..84cfe3b62d 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -269,6 +269,7 @@ private slots: void editWarning_nonEditableModelItem(); void attachedPropertiesOnEditDelegate(); void requiredPropertiesOnEditDelegate(); + void resettingRolesRespected(); }; tst_QQuickTableView::tst_QQuickTableView() @@ -7295,6 +7296,20 @@ void tst_QQuickTableView::requiredPropertiesOnEditDelegate() QCOMPARE(textInput->property("current").toBool(), false); } +void tst_QQuickTableView::resettingRolesRespected() +{ + LOAD_TABLEVIEW("resetModelData.qml"); + + TestModel model(1, 1); + tableView->setModel(QVariant::fromValue(&model)); + + WAIT_UNTIL_POLISHED; + + QVERIFY(!tableView->property("success").toBool()); + model.useCustomRoleNames(true); + QTRY_VERIFY(tableView->property("success").toBool()); +} + QTEST_MAIN(tst_QQuickTableView) #include "tst_qquicktableview.moc" |