diff options
author | ChunLin Wang <wangchunlin@uniontech.com> | 2021-03-31 17:54:49 +0800 |
---|---|---|
committer | ChunLin Wang <wangchunlin@uniontech.com> | 2021-04-07 19:30:08 +0800 |
commit | b8802071ed00689373da5817fc4824a30b5fcf86 (patch) | |
tree | 876d4485d1c86fb4702b69d67bc9b3effadcebc3 /tests/auto/corelib/itemmodels | |
parent | c10159a9a1254992867242897adb19ae1c3c3c35 (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.cpp | 17 |
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" |