From Emmanuel Roche, "I'm joining two zip files to this mail for the modified sources and include files of osgIntrospection.

The modifications I made are very small but they are absolutely usefull to use osgIntrospection with visual studio 7.1 or 8 in debug modes.
This should also solve other minor common problems (converter memory leak, virtual destructor for PropertyInfo, etc...).

I choosed two function names : Reflection::uninitialize() and Type::reset(), this can of course be changed if someone has a better idea...

I made the changes against OSG 2.2.0 public release. I tested the result with VS 7.1, VS 7.1 SP1, VS 8.0 SP1 and AQTime 5.0 on Windows XP SP2... All 4 seem to agree : they detected memory leaks before and don't anymore.

Sorry I haven't take the time to test that on linux but the changes are so small I doubt there could be a problem... I let you check that on your side  :-).

I hope this will help making OSG an even more wonderfull library."
This commit is contained in:
Robert Osfield
2008-02-25 16:26:30 +00:00
parent fb1b58b2e2
commit 3c2872a36a
6 changed files with 52 additions and 9 deletions

View File

@@ -113,12 +113,10 @@ Type* Reflection::getOrRegisterType(const ExtendedTypeInfo &ti, bool replace_if_
std::string old_namespace = i->second->getNamespace();
std::vector<std::string> old_aliases = i->second->_aliases;
Type* newtype = new (i->second) Type(ti);
newtype->_name = old_name;
newtype->_namespace = old_namespace;
newtype->_aliases.swap(old_aliases);
return newtype;
i->second->reset();
i->second->_name = old_name;
i->second->_namespace = old_namespace;
i->second->_aliases.swap(old_aliases);
}
return i->second;
}
@@ -128,7 +126,16 @@ Type* Reflection::getOrRegisterType(const ExtendedTypeInfo &ti, bool replace_if_
void Reflection::registerConverter(const Type& source, const Type& dest, const Converter* cvt)
{
const Converter* old = NULL;
StaticData::ConverterMap::iterator it = getOrCreateStaticData().convmap[&source].find(&dest);
if(it != getOrCreateStaticData().convmap[&source].end())
old = it->second;
getOrCreateStaticData().convmap[&source][&dest] = cvt;
if(old)
delete old;
}
const Converter* Reflection::getConverter(const Type& source, const Type& dest)
@@ -196,3 +203,9 @@ bool Reflection::accum_conv_path(const Type& source, const Type& dest, Converter
return false;
}
void Reflection::uninitialize() {
if(_static_data)
delete _static_data;
_static_data = 0;
}