summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/itemmodels
diff options
context:
space:
mode:
authorChunLin Wang <wangchunlin@uniontech.com>2021-03-31 17:54:49 +0800
committerChunLin Wang <wangchunlin@uniontech.com>2021-04-07 19:30:08 +0800
commitb8802071ed00689373da5817fc4824a30b5fcf86 (patch)
tree876d4485d1c86fb4702b69d67bc9b3effadcebc3 /tests/auto/corelib/itemmodels
parentc10159a9a1254992867242897adb19ae1c3c3c35 (diff)
Fix get out of bounds index in QSortFilterProxyModel::filterAcceptsRow
Before calling the index function, we need to check the validity of the parameters. Fixes: QTBUG-91878 Pick-to: 5.15 6.0 6.1 Change-Id: I9ec7265fff3f81b8a288c4ba8fae606a2ec808a6 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/corelib/itemmodels')
-rw-r--r--tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
index e1ea7a4552..90972caa57 100644
--- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
@@ -117,6 +117,7 @@ private Q_SLOTS:
void shouldPropagateDropAfterLastRow_data();
void shouldPropagateDropAfterLastRow();
void qtbug91788();
+ void qtbug91878();
private:
QStandardItemModel mod;
@@ -843,6 +844,22 @@ void tst_QConcatenateTablesProxyModel::qtbug91788()
QCOMPARE(proxyConcat.columnCount(), 0);
}
+void tst_QConcatenateTablesProxyModel::qtbug91878()
+{
+ QStandardItemModel m;
+ m.setRowCount(4);
+ m.setColumnCount(4);
+
+ QConcatenateTablesProxyModel pm;
+ QSortFilterProxyModel proxyFilter;
+ proxyFilter.setSourceModel(&pm);
+ proxyFilter.setFilterFixedString("something");
+ pm.addSourceModel(&m); // This should not assert
+
+ QCOMPARE(pm.columnCount(), 4);
+ QCOMPARE(pm.rowCount(), 4);
+}
+
QTEST_GUILESS_MAIN(tst_QConcatenateTablesProxyModel)
#include "tst_qconcatenatetablesproxymodel.moc"