- Fixed: Do not write the config file if DoGameSetup() has not been called yet.

SVN r3653 (trunk)
This commit is contained in:
Randy Heit 2012-05-15 21:47:15 +00:00
parent 1389bc08ca
commit d6cd9b430d
3 changed files with 14 additions and 1 deletions

View file

@ -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;

View file

@ -79,6 +79,8 @@ protected:
virtual char *ReadLine (char *string, int n, void *file) const;
bool ReadConfig (void *file);
bool OkayToWrite;
private:
struct FConfigEntry
{

View file

@ -84,6 +84,7 @@ FGameConfigFile::FGameConfigFile ()
#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 ()