瀏覽代碼

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 11 年之前
父節點
當前提交
db3614b585
共有 1 個文件被更改,包括 4 次插入7 次删除
  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;
 }