Browse Source

updated the process that saves user preferences so that it does not do a destructive write. It will ensure that any other blocks in the json file still remain even if they are unknown by the engine

Shaddock Heath 9 years ago
parent
commit
0f963b214d
1 changed files with 9 additions and 1 deletions
  1. 9 1
      Source/ToolCore/Project/ProjectUserPrefs.cpp

+ 9 - 1
Source/ToolCore/Project/ProjectUserPrefs.cpp

@@ -136,9 +136,17 @@ bool ProjectUserPrefs::Load(const String& path)
 
 void ProjectUserPrefs::Save(const String& path)
 {
-
     SharedPtr<JSONFile> jsonFile(new JSONFile(context_));
 
+    // Load existing prefs file if it exists and just update editor settings.  The
+    // file may contain other settings we are not aware of so we shouldn't overwrite those
+    SharedPtr<File> oldFile(new File(context_, path));
+    if (oldFile->IsOpen())
+    {
+        bool result = jsonFile->Load(*oldFile);
+        oldFile->Close();
+    }
+
     JSONValue& root = jsonFile->GetRoot();
 
     SharedPtr<File> file(new File(context_, path, FILE_WRITE));