Commit 8a499083 authored by twanvl's avatar twanvl

Found the source of the growing style file bug (and fixed it)

parent 6dc63c2d
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <util/platform.hpp> #include <util/platform.hpp>
#include <util/io/reader.hpp> #include <util/io/reader.hpp>
#include <util/io/writer.hpp> #include <util/io/writer.hpp>
#include <util/delayed_index_maps.hpp>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
...@@ -218,7 +219,18 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { ...@@ -218,7 +219,18 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(export_options); 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() { void Settings::read() {
// clear current settings, otherwise we duplicate vector elements
clear();
// (re)load settings
String filename = settingsFile(); String filename = settingsFile();
if (wxFileExists(filename)) { if (wxFileExists(filename)) {
// settings file not existing is not an error // settings file not existing is not an error
......
...@@ -171,6 +171,8 @@ class Settings { ...@@ -171,6 +171,8 @@ class Settings {
private: private:
/// Name of the settings file /// Name of the settings file
String settingsFile(); String settingsFile();
/// Clear settings before reading them
void clear();
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
......
...@@ -32,6 +32,11 @@ IndexMap<Key,Value>& DelayedIndexMaps<Key,Value>::get(const String& name, const ...@@ -32,6 +32,11 @@ IndexMap<Key,Value>& DelayedIndexMaps<Key,Value>::get(const String& name, const
return item->read_data; return item->read_data;
} }
template <typename Key, typename Value>
void DelayedIndexMaps<Key,Value>::clear() {
data.clear();
}
// ----------------------------------------------------------------------------- : Reflection // ----------------------------------------------------------------------------- : Reflection
// custom reflection : it's a template class // custom reflection : it's a template class
......
...@@ -148,6 +148,8 @@ class DelayedIndexMaps { ...@@ -148,6 +148,8 @@ class DelayedIndexMaps {
public: public:
/// Get the data for a specific name. Initialize the map with init_with (if it is not alread initialized) /// Get the data for a specific name. Initialize the map with init_with (if it is not alread initialized)
IndexMap<Key,Value>& get(const String& name, const vector<Key>& init_with); IndexMap<Key,Value>& get(const String& name, const vector<Key>& init_with);
/// Clear the delayed index map
void clear();
private: private:
map<String, intrusive_ptr<DelayedIndexMapsData<Key,Value> > > data; map<String, intrusive_ptr<DelayedIndexMapsData<Key,Value> > > data;
friend class Reader; friend class Reader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment