From de837a5d72eaa956c2d5f435ad91d5051ee714f1 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 6 Jun 2015 18:24:07 +0100 Subject: Fix memory leak config variable --- project2/common/variables/config.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/project2/common/variables/config.cpp b/project2/common/variables/config.cpp index 5b36f6e..e134d07 100644 --- a/project2/common/variables/config.cpp +++ b/project2/common/variables/config.cpp @@ -69,18 +69,23 @@ class VariableConfigLoader : public VariableLoader::For { } }; VariableConfigLoader() : - opts("Variables - ModConfig options") + opts(new Options("Variables - ModConfig options")) { - opts(new AppSettings()); - OptionsSets::Add(typeid(AppSettings).name(), &opts); + (*opts)(new AppSettings()); + OptionsSets::Add(typeid(AppSettings).name(), opts); + } + + ~VariableConfigLoader() + { + OptionsSets::Remove(typeid(AppSettings).name()); } const Options * options() const { - return &opts; + return opts; } private: - Options opts; + Options * opts; }; DECLARE_CUSTOM_COMPONENT_LOADER("config", VariableConfigLoader, VariableConfigLoader, VariableLoader); -- cgit v1.2.3