mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Fix potential crash / memory leak when clearing layouts
This commit is contained in:
parent
0a8f279e97
commit
a6ca266dab
|
|
@ -43,7 +43,7 @@ std::string getSceneItemTransform(obs_scene_item *item);
|
|||
void placeWidgets(std::string text, QBoxLayout *layout,
|
||||
std::unordered_map<std::string, QWidget *> placeholders,
|
||||
bool addStretch = true);
|
||||
void deleteLayoutItem(QLayoutItem *item);
|
||||
void deleteLayoutItemWidget(QLayoutItem *item);
|
||||
void clearLayout(QLayout *layout, int afterIdx = 0);
|
||||
void setLayoutVisible(QLayout *layout, bool visible);
|
||||
QMetaObject::Connection PulseWidget(QWidget *widget, QColor startColor,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user