From e4944a067c3624a669c4703bfa0d5dce5f1b4119 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 4 Jun 2020 21:24:44 +0200 Subject: [PATCH] change made was wrong (pointers in map are not deleted!) --- objectmanager/ObjectManager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index a5895098a..b12c66d9b 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -9,7 +9,9 @@ ObjectManager::ObjectManager( void (*setProducer)() ): ObjectManager::~ObjectManager() { - // Map is STL object and deletes its own pointers. + for (auto const& iter : objectList) { + delete iter.second; + } } ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { @@ -99,7 +101,7 @@ void ObjectManager::initialize() { void ObjectManager::printList() { std::map::iterator it; sif::debug << "ObjectManager: Object List contains:" << std::endl; - for (it = this->objectList.begin(); it != this->objectList.end(); it++) { - sif::debug << std::hex << it->first << " | " << it->second << std::endl; + for (auto const& it : objectList) { + sif::debug << std::hex << it.first << " | " << it.second << std::endl; } }