[Orxonox-commit 1100] r5821 - code/branches/core5/src/libraries/core
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon Sep 28 15:56:30 CEST 2009
Author: rgrieder
Date: 2009-09-28 15:56:30 +0200 (Mon, 28 Sep 2009)
New Revision: 5821
Modified:
code/branches/core5/src/libraries/core/BaseObject.cc
code/branches/core5/src/libraries/core/ClassTreeMask.cc
code/branches/core5/src/libraries/core/Identifier.cc
Log:
Fixed 3 memory leaks (one of them was a true even a true one ;))
- XMLPortObjectContainers as XMLPort event containers were not deleted in the identifier
- EventContainers were not deleted in the BaseObject
- ClassTreeMask clean() operation only erased redundant subnodes instead of deleting them as well
Modified: code/branches/core5/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/core5/src/libraries/core/BaseObject.cc 2009-09-28 00:55:47 UTC (rev 5820)
+++ code/branches/core5/src/libraries/core/BaseObject.cc 2009-09-28 13:56:30 UTC (rev 5821)
@@ -98,6 +98,9 @@
for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
it->first->removeEvent(this);
+ for (std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.begin(); it != this->eventContainers_.end(); ++it)
+ delete it->second;
+
if (this->functorSetMainState_)
delete this->functorSetMainState_;
if (this->functorGetMainState_)
@@ -145,7 +148,7 @@
loadexecutor->setDefaultValue(1, sectionname);
XMLPortClassObjectContainer<BaseObject, BaseObject>* container = 0;
- container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(this->getIdentifier()->getXMLPortEventContainer(sectionname));
+ container = static_cast<XMLPortClassObjectContainer<BaseObject, BaseObject>*>(this->getIdentifier()->getXMLPortEventContainer(sectionname));
if (!container)
{
container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(sectionname, this->getIdentifier(), loadexecutor, saveexecutor, false, true);
Modified: code/branches/core5/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/branches/core5/src/libraries/core/ClassTreeMask.cc 2009-09-28 00:55:47 UTC (rev 5820)
+++ code/branches/core5/src/libraries/core/ClassTreeMask.cc 2009-09-28 13:56:30 UTC (rev 5821)
@@ -487,6 +487,7 @@
(*it)->subnodes_.clear();
// Remove the redundant subnode from the current node
+ delete (*it);
node->subnodes_.erase(it++);
}
else
Modified: code/branches/core5/src/libraries/core/Identifier.cc
===================================================================
--- code/branches/core5/src/libraries/core/Identifier.cc 2009-09-28 00:55:47 UTC (rev 5820)
+++ code/branches/core5/src/libraries/core/Identifier.cc 2009-09-28 13:56:30 UTC (rev 5821)
@@ -87,6 +87,8 @@
delete (it->second);
for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
delete (it->second);
+ for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportEventContainers_.begin(); it != this->xmlportEventContainers_.end(); ++it)
+ delete (it->second);
}
/**
More information about the Orxonox-commit
mailing list