tst_QAbstractItemModelTester: fix mem-leak

QThreeWidgetItems that have been removed from their parents (or the
widget) must be deleted manually. The treeWidgetModel() test forgot
that, driving asan nuts.

Code predates the beginning of the public history, so picking to all
active branches.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I139549b0bd8baf4abfb90f926f6290119471046f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
bb10
Marc Mutz 2023-07-14 20:00:13 +02:00
parent bad3b8f78b
commit 51edc438dd
1 changed files with 1 additions and 0 deletions

View File

@ -54,6 +54,7 @@ void tst_QAbstractItemModelTester::treeWidgetModel()
new QTreeWidgetItem(root, QStringList(QString::number(i)));
QTreeWidgetItem *remove = root->child(2);
root->removeChild(remove);
delete remove;
QTreeWidgetItem *parent = new QTreeWidgetItem(&widget, QStringList("parent"));
new QTreeWidgetItem(parent, QStringList("child"));
parent->setHidden(true);