aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-23 14:16:07 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-08-23 13:57:20 +0000
commitee0713e3988b0acf3a1ec6cad1c7722dbec76ea7 (patch)
tree6dbf89401f77f0d07f00ac9c4013e200c02a2d2a /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
parent7c55485b75548fe6538f6d5227066640a2cbb878 (diff)
QQuickTableView: don't overwrite rebuildState
Since it's fully possible to end up calling invalidateTable() while in the process of rebuilding the table, we need to ensure that we don't mess with the current rebuildState. Instead, just schedule that we need to rebuild once more later. Change-Id: If27bb14f0bc9f72c53eb47e6115d7ad580cdb516 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.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index ea3531ba13..5e1c21fce8 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -128,6 +128,7 @@ private slots:
void checkContextPropertiesQQmlListProperyModel_data();
void checkContextPropertiesQQmlListProperyModel();
void checkRowAndColumnChangedButNotIndex();
+ void checkChangingModelFromDelegate();
};
tst_QQuickTableView::tst_QQuickTableView()
@@ -1622,6 +1623,34 @@ void tst_QQuickTableView::checkRowAndColumnChangedButNotIndex()
QCOMPARE(contextColumn, 1);
}
+void tst_QQuickTableView::checkChangingModelFromDelegate()
+{
+ // Check that we don't restart a rebuild of the table
+ // while we're in the middle of rebuilding it from before
+ LOAD_TABLEVIEW("changemodelfromdelegate.qml");
+
+ // Set addRowFromDelegate. This will trigger the QML code to add a new
+ // row and call forceLayout(). When TableView instantiates the first
+ // delegate in the new row, the Component.onCompleted handler will try to
+ // add a new row. But since we're currently rebuilding, this should be
+ // scheduled for later.
+ view->rootObject()->setProperty("addRowFromDelegate", true);
+
+ // We now expect two rows in the table, one more than initially
+ QCOMPARE(tableViewPrivate->tableSize.height(), 2);
+ QCOMPARE(tableViewPrivate->loadedTable.height(), 2);
+
+ // And since the QML code tried to add another row as well, we
+ // expect rebuildScheduled to be true, and a polish event to be pending.
+ QCOMPARE(tableViewPrivate->rebuildScheduled, true);
+ QCOMPARE(tableViewPrivate->polishScheduled, true);
+ WAIT_UNTIL_POLISHED;
+
+ // After handling the polish event, we expect also the third row to now be added
+ QCOMPARE(tableViewPrivate->tableSize.height(), 3);
+ QCOMPARE(tableViewPrivate->loadedTable.height(), 3);
+}
+
QTEST_MAIN(tst_QQuickTableView)
#include "tst_qquicktableview.moc"