Fixed effective leak in Program::PerContextProgram caused by previously osg::State keeping a set of std::ref_ptr<Program::PerContextProgram> without ever pruning this list.

The fix was to convert the osg::State to use C pointers for the set of applied PerContexProgram objects, and use the osg::Oberver mechanism to avoid dangling pointers for being maintained in osg::State.
This commit is contained in:
Robert Osfield
2009-01-26 15:16:24 +00:00
parent 55a0381687
commit 69f9377093
5 changed files with 47 additions and 10 deletions

View File

@@ -90,6 +90,23 @@ State::State():
State::~State()
{
for(AppliedProgramObjectSet::iterator itr = _appliedProgramObjectSet.begin();
itr != _appliedProgramObjectSet.end();
++itr)
{
(*itr)->removeObserver(this);
}
}
void State::objectDeleted(void* object)
{
const Program::PerContextProgram* ppcp = reinterpret_cast<const Program::PerContextProgram*>(object);
AppliedProgramObjectSet::iterator itr = _appliedProgramObjectSet.find(ppcp);
if (itr != _appliedProgramObjectSet.end())
{
osg::notify(osg::NOTICE)<<"Removing _appliedProgramObjectSet entry "<<ppcp<<std::endl;
_appliedProgramObjectSet.erase(itr);
}
}
void State::reset()