UI: Use saving functions for profiles/scenes

Replaces all the json/config loading/saving functions with safe
variants to reduce the chance of potential file corruption as much as
possible.

Also does a minor refactor of json writing by using
obs_data_save_json_safe for writing json files instead of manually using
obs_data_get_json and os_quick_write_utf8 each time.
This commit is contained in:
jp9000
2015-08-21 18:22:25 -07:00
parent e479d4d0dc
commit ebf3abf04e
4 changed files with 33 additions and 52 deletions
+4 -4
View File
@@ -225,7 +225,7 @@ bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
newDir.c_str());
config_set_string(config, "General", "Name", newName.c_str());
config.Save();
config.SaveSafe("tmp");
config.Swap(basicConfig);
InitBasicConfigDefaults();
RefreshProfiles();
@@ -237,7 +237,7 @@ bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
create_new ? "clean" : "duplicate", newDir.c_str());
blog(LOG_INFO, "------------------------------------------------");
config_save(App()->GlobalConfig());
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
UpdateTitleBar();
return true;
}
@@ -424,7 +424,7 @@ void OBSBasic::on_actionRemoveProfile_triggered()
ResetProfileData();
DeleteProfile(oldName.c_str(), oldDir.c_str());
RefreshProfiles();
config_save(App()->GlobalConfig());
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
blog(LOG_INFO, "Switched to profile '%s' (%s)",
newName.c_str(), newDir);
@@ -475,7 +475,7 @@ void OBSBasic::ChangeProfile()
InitBasicConfigDefaults();
ResetProfileData();
RefreshProfiles();
config_save(App()->GlobalConfig());
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
UpdateTitleBar();
blog(LOG_INFO, "Switched to profile '%s' (%s)",