Commit cbaa11ce authored by Sylvain Thery's avatar Sylvain Thery

correctly delete registry at map destruction (thanks to valgrind)

parent c4277eaa
......@@ -83,6 +83,8 @@ protected:
static std::map<std::string, RegisteredBaseAttribute*>* m_attributes_registry_map ;
static int m_nbInstances;
/**
* Direct access to the Dart attributes that store the orbits embeddings
* (only initialized when necessary)
......
......@@ -34,12 +34,15 @@ namespace CGoGN
{
std::map<std::string, RegisteredBaseAttribute*>* GenericMap::m_attributes_registry_map = NULL ;
int GenericMap::m_nbInstances = 0;
GenericMap::GenericMap() : m_nbThreads(1)
{
if(m_attributes_registry_map == NULL)
m_attributes_registry_map = new std::map<std::string, RegisteredBaseAttribute*> ;
m_nbInstances++;
// register all known types
registerAttribute<Dart>("Dart");
registerAttribute<Mark>("Mark");
......@@ -115,8 +118,19 @@ GenericMap::~GenericMap()
(*it)->setReleaseOnDestruct(false) ;
cellMarkers.clear() ;
if(m_attributes_registry_map)
// if(m_attributes_registry_map)
// {
// delete m_attributes_registry_map;
// m_attributes_registry_map = NULL;
// }
// clean type registry if necessary
m_nbInstances--;
if (m_nbInstances<=0)
{
for (std::map<std::string, RegisteredBaseAttribute*>::iterator it = m_attributes_registry_map->begin(); it != m_attributes_registry_map->end(); ++it)
delete it->second;
delete m_attributes_registry_map;
m_attributes_registry_map = NULL;
}
......
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