summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-12-30 14:03:18 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-01-05 08:22:00 +0100
commit9f713e8d25c330cc9ab598755b81b9881df830e8 (patch)
tree45be578f20b5d5d53ebc0a656ca4d9b001a133bd
parenteabaa8a08e647273978f5786729776213e326aca (diff)
tst_QItemModel: fix memleaks
When creating proxied models, make the source model a QObject child of the proxy model, so the source isn't leaked when the proxy is deleted. This drove asan nuts. Pick-to: 6.3 6.2 5.15 Change-Id: I0f7fc9ab8e99d030c941cfb336ee4e2323b362ae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
index 3eb6c15ec2..cdbeaccac6 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp
@@ -142,14 +142,14 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
if (modelType == "QSortFilterProxyModelEmpty") {
QSortFilterProxyModel *model = new QSortFilterProxyModel;
- QStandardItemModel *standardItemModel = new QStandardItemModel;
+ QStandardItemModel *standardItemModel = new QStandardItemModel(model);
model->setSourceModel(standardItemModel);
return model;
}
if (modelType == "QSortFilterProxyModelRegExp") {
QSortFilterProxyModel *model = new QSortFilterProxyModel;
- QStandardItemModel *standardItemModel = new QStandardItemModel;
+ QStandardItemModel *standardItemModel = new QStandardItemModel(model);
model->setSourceModel(standardItemModel);
populateTestArea(model);
model->setFilterRegularExpression(QRegularExpression("(^$|I.*)"));
@@ -158,7 +158,7 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
if (modelType == "QSortFilterProxyModel") {
QSortFilterProxyModel *model = new QSortFilterProxyModel;
- QStandardItemModel *standardItemModel = new QStandardItemModel;
+ QStandardItemModel *standardItemModel = new QStandardItemModel(model);
model->setSourceModel(standardItemModel);
populateTestArea(model);
return model;