summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-05-25 21:06:43 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-05-26 11:24:53 +0000
commite15fc26e9fdbff141890a3e2e8dc4ef935d022a0 (patch)
treee905dfc7c13c58f22e92113340f8a274fdf3917d /tests/auto
parent8050f1c287490ec6130e85e83beb55dccab0294d (diff)
QSortFilterProxyModel: don't assert when old model gets destroyed
When a new model was set with setSourceModel() and the mapping was built up, the destruction of the old model caused a reset in the QSortFilterProxyModel which lead to an empty view or an assertion. Now we properly disconnect the old model again and also clean up the old mapping/persistent indexes when a new source model is set. Task-number: QTBUG-44962 Task-number: QTBUG-67948 Task-number: QTBUG-68427 Change-Id: I2e0612899c210bde3ac0cfa59aefd78269deee5b Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 1acedf4271..296442b0c7 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -4516,15 +4516,25 @@ void tst_QSortFilterProxyModel::checkSetNewModel()
QTreeView tv;
StepTreeModel model1;
model1.setDepth(4);
- StepTreeModel model2;
- model2.setDepth(4);
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model1);
tv.setModel(&proxy);
tv.show();
- tv.expandAll(); // create persistent indexes
- proxy.setSourceModel(&model2);
+ QVERIFY(QTest::qWaitForWindowExposed(&tv));
+ tv.expandAll();
+ {
+ StepTreeModel model2;
+ model2.setDepth(4);
+ proxy.setSourceModel(&model2);
+ tv.expandAll();
+ proxy.setSourceModel(&model1);
+ tv.expandAll();
+ // the destruction of model2 here caused a proxy model reset due to
+ // missing disconnect in setSourceModel()
+ }
+ // handle repaint events, will assert when qsortfilterproxymodel is in wrong state
+ QCoreApplication::processEvents();
}
QTEST_MAIN(tst_QSortFilterProxyModel)