Explorar o código

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.
jp9000 %!s(int64=11) %!d(string=hai) anos
pai
achega
db3614b585
Modificáronse 1 ficheiros con 4 adicións e 7 borrados
  1. 4 7
      obs/properties-view.cpp

+ 4 - 7
obs/properties-view.cpp

@@ -623,17 +623,13 @@ bool WidgetInfo::FontChanged(const char *setting)
 	} else {
 		MakeQFont(font_obj, font);
 		font = QFontDialog::getFont(&success, font, view);
+		obs_data_release(font_obj);
 	}
 
-	if (!success) {
-		obs_data_release(font_obj);
+	if (!success)
 		return false;
-	}
 
-	if (!font_obj) {
-		font_obj = obs_data_create();
-		obs_data_set_obj(view->settings, setting, font_obj);
-	}
+	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;
 }