diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-08-22 14:02:46 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-08-22 15:44:38 +0000 |
commit | cd5937273ee14c3941574a2db7cc0f8c3682def0 (patch) | |
tree | 062e1b4700c0270278046b3f5eb505b56305d44d /tests/auto/quick/qquicktableview | |
parent | 0eb65826c85aee9431c1a1f4ef3289abac2ae27d (diff) |
QQuickTableView: drain pool upon setting reuseItems to false
As (soon to be) documented, drain the pool immediately when setting
reuseItems to false. This will give developers a way to clear
the pool if e.g running low on memory. Besides, there is no reason
to keep items in the pool if we're not reusing them.
Change-Id: I49f0283721a63c6a6b92631f00c7ad711a262978
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview')
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index e4ac5b805b..b49164a78c 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -119,6 +119,7 @@ private slots: void checkRowColumnCount(); void modelSignals(); void dataChangedSignal(); + void checkThatPoolIsDrainedWhenReuseIsFalse(); void checkIfDelegatesAreReused_data(); void checkIfDelegatesAreReused(); void checkIfDelegatesAreReusedAsymmetricTableSize(); @@ -1309,6 +1310,24 @@ void tst_QQuickTableView::dataChangedSignal() } } +void tst_QQuickTableView::checkThatPoolIsDrainedWhenReuseIsFalse() +{ + // Check that the reuse pool is drained + // immediately when setting reuseItems to false. + LOAD_TABLEVIEW("countingtableview.qml"); + + auto model = TestModelAsVariant(100, 100); + tableView->setModel(model); + + WAIT_UNTIL_POLISHED; + + // The pool should now contain preloaded items + QVERIFY(tableViewPrivate->tableModel->poolSize() > 0); + tableView->setReuseItems(false); + // The pool should now be empty + QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0); +} + void tst_QQuickTableView::checkIfDelegatesAreReused_data() { QTest::addColumn<bool>("reuseItems"); |