first time wizard "overwrite": obey default console sources

this is actually not a FTW issue but rather a console sources issue.

the console log sources are not c++ classes and therefore don't get initialized
other than when [attempting to] loading them from the ini file (where if the ini
doesn't exist then they get their default values). however, during first time
wizard, when choosing "overwrite", the console sources are saved without ever
getting loaded and so end up without the default values applied (so all sources
as disabled).

this patch makes sure that if we're saving the conlog sources before ever
attempting to load them, they'll get saved with the correct default values.
This commit is contained in:
Avi Halachmi (:avih) 2015-04-16 12:55:55 +03:00
parent ce8626150e
commit 2c3b3eafbe
1 changed files with 12 additions and 0 deletions

View File

@ -350,6 +350,13 @@ static const bool ConLogDefaults[] =
false
};
// Typically on startup (or during first time wizard when choosing "import"), the
// settings are loaded from ini and if the ini doesn't exist then from ConLogDefaults,
// but during first time wizard when choosing "overwrite", the first action is "save",
// which ends up saving before applying ConLogDefaults, therefore all conlog sources
// are saved as disabled. ConLogInitialized is used to detect and avoid this issue.
static bool ConLogInitialized = false;
void ConLog_LoadSaveSettings( IniInterface& ini )
{
ScopedIniGroup path(ini, L"ConsoleLogSources");
@ -361,9 +368,14 @@ void ConLog_LoadSaveSettings( IniInterface& ini )
{
if (ConsoleLogSource* log = ConLogSources[i])
{
// IsSaving() is for clarity only, since log->Enabled initial value is ignored when loading.
if (ini.IsSaving() && !ConLogInitialized)
log->Enabled = ConLogDefaults[i];
ini.Entry( log->GetCategory() + L"." + log->GetShortName(), log->Enabled, ConLogDefaults[i] );
}
}
ConLogInitialized = true;
}