summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/itemmodels
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-11-11 17:42:36 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-11-12 11:21:50 +0100
commitab4bb5077cc82bed1f5c297f1753a68ed5fb49f1 (patch)
tree25f058f8b1fe63e627a400756cba19f212f0d244 /tests/auto/gui/itemmodels
parent0416e080cffe33de435631b5d47d3acbbcb7b880 (diff)
tst_qstandarditemmodel: fix memleaks
QStandardItemModel::takeItem/Row/Column() return items not owned by the model anymore and therefore need to be cleaned up manually Pick-to: 6.6 Fixes: QTBUG-116532 Change-Id: Ic8797f58184f56b9c4ef415ce8f2363c1b352388 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/gui/itemmodels')
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index 7489b7bf13..fb4749e5bc 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -1614,15 +1614,21 @@ void tst_QStandardItemModel::removeRowsAndColumns()
QList<QStandardItem *> row_taken = model.takeRow(6);
QCOMPARE(row_taken.size(), col_list.size());
- for (int c = 0; c < col_list.size(); c++)
- QCOMPARE(row_taken[c]->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
+ for (qsizetype c = 0; c < row_taken.size(); c++) {
+ auto item = row_taken.at(c);
+ QCOMPARE(item->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
+ delete item;
+ }
row_list.remove(6);
VERIFY_MODEL
QList<QStandardItem *> col_taken = model.takeColumn(10);
QCOMPARE(col_taken.size(), row_list.size());
- for (int r = 0; r < row_list.size(); r++)
- QCOMPARE(col_taken[r]->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
+ for (qsizetype r = 0; r < col_taken.size(); r++) {
+ auto item = col_taken.at(r);
+ QCOMPARE(item->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
+ delete item;
+ }
col_list.remove(10);
VERIFY_MODEL
}
@@ -1792,6 +1798,7 @@ void tst_QStandardItemModel::signalsOnTakeItem() // QTBUG-89145
QCOMPARE(takenItem->model(), nullptr);
QCOMPARE(takenItem->child(0, 0)->model(), nullptr);
QCOMPARE(m.index(1, 0).data(), QVariant());
+ delete takenItem;
}
void tst_QStandardItemModel::createPersistentOnLayoutAboutToBeChanged() // QTBUG-93466