Always create new object when setting a sub-object

Do not use the object returned from obs_data_get_obj to set new
settings.  It could be the default object, which means you'd just end up
modifying the default data, which won't get saved.  Always create a new
object when setting sub-object data.  It doesn't particularly hurt
anything.
This commit is contained in:
jp9000 2014-08-22 15:48:19 -07:00
parent 1bbdcc10d7
commit db3614b585

View file

@ -623,17 +623,13 @@ bool WidgetInfo::FontChanged(const char *setting)
} else {
MakeQFont(font_obj, font);
font = QFontDialog::getFont(&success, font, view);
}
if (!success) {
obs_data_release(font_obj);
return false;
}
if (!font_obj) {
font_obj = obs_data_create();
obs_data_set_obj(view->settings, setting, font_obj);
}
if (!success)
return false;
font_obj = obs_data_create();
obs_data_set_string(font_obj, "face", QT_TO_UTF8(font.family()));
obs_data_set_string(font_obj, "style", QT_TO_UTF8(font.styleName()));
@ -648,6 +644,7 @@ bool WidgetInfo::FontChanged(const char *setting)
label->setFont(font);
label->setText(QString("%1 %2").arg(font.family(), font.styleName()));
obs_data_set_obj(view->settings, setting, font_obj);
obs_data_release(font_obj);
return true;
}