From d6cd9b430d08c39d2463d6338376973cf2655838 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 15 May 2012 21:47:15 +0000 Subject: [PATCH] - Fixed: Do not write the config file if DoGameSetup() has not been called yet. SVN r3653 (trunk) --- src/configfile.cpp | 9 +++++++++ src/configfile.h | 2 ++ src/gameconfigfile.cpp | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index 2a6d449a4..b379bcf2a 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -53,6 +53,7 @@ FConfigFile::FConfigFile () LastSectionPtr = &Sections; CurrentEntry = NULL; PathName = ""; + OkayToWrite = true; } //==================================================================== @@ -70,6 +71,7 @@ FConfigFile::FConfigFile (const char *pathname, CurrentEntry = NULL; ChangePathName (pathname); LoadConfigFile (nosechandler, userdata); + OkayToWrite = true; } //==================================================================== @@ -85,6 +87,7 @@ FConfigFile::FConfigFile (const FConfigFile &other) CurrentEntry = NULL; ChangePathName (other.PathName); *this = other; + OkayToWrite = other.OkayToWrite; } //==================================================================== @@ -695,6 +698,12 @@ char *FConfigFile::ReadLine (char *string, int n, void *file) const bool FConfigFile::WriteConfigFile () const { + if (!OkayToWrite) + { // Pretend it was written anyway so that the user doesn't get + // any "config not written" notifications. + return true; + } + FILE *file = fopen (PathName, "w"); FConfigSection *section; FConfigEntry *entry; diff --git a/src/configfile.h b/src/configfile.h index 0a058e40f..173d6fede 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -79,6 +79,8 @@ protected: virtual char *ReadLine (char *string, int n, void *file) const; bool ReadConfig (void *file); + bool OkayToWrite; + private: struct FConfigEntry { diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 726031f6d..156973443 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -83,7 +83,8 @@ FGameConfigFile::FGameConfigFile () FString user_docs, user_app_support, local_app_support; #endif FString pathname; - + + OkayToWrite = false; // Do not allow saving of the config before DoGameSetup() bMigrating = false; pathname = GetConfigPath (true); ChangePathName (pathname); @@ -441,6 +442,7 @@ void FGameConfigFile::DoGameSetup (const char *gamename) } } } + OkayToWrite = true; } void FGameConfigFile::ReadNetVars ()