From 82d55799ee319bf2db357f2d5aded01ad0e2076f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 17 Jan 2021 12:50:10 +0200 Subject: [PATCH] Make Loader::ActionMap delete the actions This ensures actions in shared action maps are deleted as well --- source/loader.cpp | 13 +++++++------ source/loader.h | 8 ++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/loader.cpp b/source/loader.cpp index 6a4a8d8..960621c 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -54,12 +54,6 @@ Loader::Loader(): check_sub_loads(false) { } -Loader::~Loader() -{ - for(ActionMap::iterator i=local_actions.begin(); i!=local_actions.end(); ++i) - delete i->second; -} - void Loader::load(Parser &p) { if(!actions) @@ -249,5 +243,12 @@ const string &Loader::get_keyword() const return cur_st->keyword; } + +Loader::ActionMap::~ActionMap() +{ + for(iterator i=begin(); i!=end(); ++i) + delete i->second; +} + } // namespace DataFile } // namespace Msp diff --git a/source/loader.h b/source/loader.h index 9736d26..fe8f0aa 100644 --- a/source/loader.h +++ b/source/loader.h @@ -36,7 +36,11 @@ See also classes ObjectLoader and CollectionObjectLoader in objectloader.h. class Loader: private NonCopyable { protected: - typedef std::map ActionMap; + class ActionMap: public std::map, private NonCopyable + { + public: + ~ActionMap(); + }; private: ActionMap local_actions; @@ -52,7 +56,7 @@ protected: Loader(); public: - virtual ~Loader(); + virtual ~Loader() { } /** Loads statements from a parser. */ void load(Parser &p); -- 2.45.2