Fixed a memory leak in Settings.

This commit is contained in:
Leon Styhre 2021-03-19 18:40:37 +01:00
parent b90ab39cb7
commit 924b3ac033
3 changed files with 11 additions and 0 deletions

View file

@ -616,6 +616,7 @@ int main(int argc, char* argv[])
CollectionSystemsManager::deinit();
SystemData::deleteSystems();
NavigationSounds::getInstance()->deinit();
Settings::deinit();
// Call this ONLY when linking with FreeImage as a static library.
#if defined(FREEIMAGE_LIB)

View file

@ -72,10 +72,19 @@ Settings* Settings::getInstance()
return sInstance;
}
void Settings::deinit()
{
if (sInstance) {
delete sInstance;
sInstance = nullptr;
}
}
void Settings::setDefaults()
{
mBoolMap.clear();
mIntMap.clear();
mStringMap.clear();
// All settings are in pairs of default values and current values.
// As such, in this function we set these pairs identically.

View file

@ -18,6 +18,7 @@ class Settings
{
public:
static Settings* getInstance();
static void deinit();
void loadFile();
void saveFile();