UI: Fix QLabel leak in OBSPropertiesView::AddProperty

OBS_PROPERTY_GROUP creates neither a widget nor a label, causing
AddProperty to create a default one. Without a widget, it does not
get attached to the layout, resulting in a memory leak.

This commit also simplifies a bit of the code to avoid repeatedly
testing the same condition.
This commit is contained in:
Richard Stanway 2022-01-24 02:21:22 +01:00 committed by Jim
parent 799ac3f6a0
commit 40a598008d

View file

@ -1452,27 +1452,32 @@ void OBSPropertiesView::AddProperty(obs_property_t *property,
AddColorAlpha(property, layout, label);
}
if (widget && !obs_property_enabled(property))
widget->setEnabled(false);
if (!widget && !label)
return;
if (!label && type != OBS_PROPERTY_BOOL &&
type != OBS_PROPERTY_BUTTON && type != OBS_PROPERTY_GROUP)
label = new QLabel(QT_UTF8(obs_property_description(property)));
if (warning && label) //TODO: select color based on background color
label->setStyleSheet("QLabel { color: red; }");
if (label) {
if (warning) //TODO: select color based on background color
label->setStyleSheet("QLabel { color: red; }");
if (label && minSize) {
label->setMinimumWidth(minSize);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
if (minSize) {
label->setMinimumWidth(minSize);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
}
if (!obs_property_enabled(property))
label->setEnabled(false);
}
if (label && !obs_property_enabled(property))
label->setEnabled(false);
if (!widget)
return;
if (!obs_property_enabled(property))
widget->setEnabled(false);
if (obs_property_long_description(property)) {
bool lightTheme = palette().text().color().redF() < 0.5;
QString file = lightTheme ? ":/res/images/help.svg"