mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-30 05:06:14 -05:00
Fix potential crash / memory leak when clearing layouts
This commit is contained in:
@@ -204,12 +204,13 @@ void placeWidgets(std::string text, QBoxLayout *layout,
|
||||
}
|
||||
}
|
||||
|
||||
void deleteLayoutItem(QLayoutItem *item)
|
||||
void deleteLayoutItemWidget(QLayoutItem *item)
|
||||
{
|
||||
if (item) {
|
||||
auto widget = item->widget();
|
||||
if (widget) {
|
||||
widget->setVisible(false);
|
||||
widget->deleteLater();
|
||||
}
|
||||
delete item;
|
||||
}
|
||||
@@ -223,10 +224,7 @@ void clearLayout(QLayout *layout, int afterIdx)
|
||||
clearLayout(item->layout());
|
||||
delete item->layout();
|
||||
}
|
||||
if (item->widget()) {
|
||||
delete item->widget();
|
||||
}
|
||||
delete item;
|
||||
deleteLayoutItemWidget(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user