mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-05 15:16:13 -05:00
UI: Fix potential memory leak in properties
When hitting the Cancel button, cleanup code needs to go through the reject() callback as well.
This commit is contained in:
@@ -55,6 +55,9 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
||||
if (cx > 400 && cy > 400)
|
||||
resize(cx, cy);
|
||||
|
||||
/* The OBSData constructor increments the reference once */
|
||||
obs_data_release(oldSettings);
|
||||
|
||||
OBSData settings = obs_source_get_settings(source);
|
||||
obs_data_apply(oldSettings, settings);
|
||||
obs_data_release(settings);
|
||||
@@ -193,6 +196,32 @@ void OBSBasicProperties::timerEvent(QTimerEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void OBSBasicProperties::Cleanup()
|
||||
{
|
||||
// remove draw callback and release display in case our drawable
|
||||
// surfaces go away before the destructor gets called
|
||||
obs_display_remove_draw_callback(display,
|
||||
OBSBasicProperties::DrawPreview, this);
|
||||
display = nullptr;
|
||||
|
||||
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cx",
|
||||
width());
|
||||
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy",
|
||||
height());
|
||||
}
|
||||
|
||||
void OBSBasicProperties::reject()
|
||||
{
|
||||
if (!acceptClicked && (CheckSettings() != 0)) {
|
||||
if (!ConfirmQuit()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup();
|
||||
done(0);
|
||||
}
|
||||
|
||||
void OBSBasicProperties::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!acceptClicked && (CheckSettings() != 0)) {
|
||||
@@ -206,18 +235,7 @@ void OBSBasicProperties::closeEvent(QCloseEvent *event)
|
||||
if (!event->isAccepted())
|
||||
return;
|
||||
|
||||
obs_data_release(oldSettings);
|
||||
|
||||
// remove draw callback and release display in case our drawable
|
||||
// surfaces go away before the destructor gets called
|
||||
obs_display_remove_draw_callback(display,
|
||||
OBSBasicProperties::DrawPreview, this);
|
||||
display = nullptr;
|
||||
|
||||
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cx",
|
||||
width());
|
||||
config_set_int(App()->GlobalConfig(), "PropertiesWindow", "cy",
|
||||
height());
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
void OBSBasicProperties::Init()
|
||||
|
||||
Reference in New Issue
Block a user