Avoid potential leak of memory pointed to by QTreeWidgetItem subcatItem

This commit is contained in:
Stephan Witt 2020-02-21 07:57:09 +01:00
parent d2257bb0ff
commit aec491f686

View File

@ -445,7 +445,7 @@ void GuiLyXFiles::updateContents()
if (subcat.isEmpty())
catItem->addChild(item);
else {
QTreeWidgetItem * subcatItem = new QTreeWidgetItem();
QTreeWidgetItem * subcatItem = nullptr;
if (cats.contains(catsave)) {
QList<QTreeWidgetItem *> pcats = filesLW->findItems(cat, Qt::MatchExactly);
for (int iit = 0; iit < pcats.size(); ++iit) {
@ -456,7 +456,9 @@ void GuiLyXFiles::updateContents()
}
}
}
} else {
}
if (!subcatItem) {
subcatItem = new QTreeWidgetItem();
subcatItem->setText(0, subcat);
subcatItem->setIcon(0, file_icon);
cats << catsave;