From e200c6839a6771ffb9b16b5fb5d51c0e274f5e61 Mon Sep 17 00:00:00 2001 From: twanvl Date: Wed, 29 Aug 2007 15:51:04 +0000 Subject: [PATCH] Found the source of the growing style file bug (and fixed it) git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@645 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/settings.cpp | 12 ++++++++++++ src/data/settings.hpp | 2 ++ src/util/delayed_index_maps.hpp | 5 +++++ src/util/index_map.hpp | 2 ++ 4 files changed, 21 insertions(+) diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 76d20dac..36d1a605 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -218,7 +219,18 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { REFLECT(export_options); } +void Settings::clear() { + recent_sets.clear(); + game_settings.clear(); + stylesheet_settings.clear(); + default_stylesheet_settings = StyleSheetSettings(); + export_options.clear(); +} + void Settings::read() { + // clear current settings, otherwise we duplicate vector elements + clear(); + // (re)load settings String filename = settingsFile(); if (wxFileExists(filename)) { // settings file not existing is not an error diff --git a/src/data/settings.hpp b/src/data/settings.hpp index b4124e21..274008d6 100644 --- a/src/data/settings.hpp +++ b/src/data/settings.hpp @@ -171,6 +171,8 @@ class Settings { private: /// Name of the settings file String settingsFile(); + /// Clear settings before reading them + void clear(); DECLARE_REFLECTION(); }; diff --git a/src/util/delayed_index_maps.hpp b/src/util/delayed_index_maps.hpp index aa694391..73fc0b1a 100644 --- a/src/util/delayed_index_maps.hpp +++ b/src/util/delayed_index_maps.hpp @@ -32,6 +32,11 @@ IndexMap& DelayedIndexMaps::get(const String& name, const return item->read_data; } +template +void DelayedIndexMaps::clear() { + data.clear(); +} + // ----------------------------------------------------------------------------- : Reflection // custom reflection : it's a template class diff --git a/src/util/index_map.hpp b/src/util/index_map.hpp index fbce1c08..aaf1e4f3 100644 --- a/src/util/index_map.hpp +++ b/src/util/index_map.hpp @@ -148,6 +148,8 @@ class DelayedIndexMaps { public: /// Get the data for a specific name. Initialize the map with init_with (if it is not alread initialized) IndexMap& get(const String& name, const vector& init_with); + /// Clear the delayed index map + void clear(); private: map > > data; friend class Reader;