Fixed memory leak associated with VertexArrayStte objects not getting released on destruction of Geometry/Drawables.
This commit is contained in:
parent
ed13576d03
commit
3808b298d1
@ -256,7 +256,7 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
dirtyGLObjects();
|
||||
Drawable::releaseGLObjects();
|
||||
}
|
||||
|
||||
osg::MatrixList Drawable::getWorldMatrices(const osg::Node* haltTraversalAtNode) const
|
||||
@ -340,7 +340,26 @@ void Drawable::releaseGLObjects(State* state) const
|
||||
}
|
||||
else
|
||||
{
|
||||
const_cast<Drawable*>(this)->dirtyGLObjects();
|
||||
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
for(unsigned int i=0;i<_globjList.size();++i)
|
||||
{
|
||||
if (_globjList[i] != 0)
|
||||
{
|
||||
Drawable::deleteDisplayList(i,_globjList[i], getGLObjectSizeHint());
|
||||
_globjList[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for(unsigned int i=0; i<_vertexArrayStateList.size(); ++i)
|
||||
{
|
||||
VertexArrayState* vas = _vertexArrayStateList[i].get();
|
||||
if (vas)
|
||||
{
|
||||
vas->release();
|
||||
_vertexArrayStateList[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,9 +453,8 @@ void Drawable::setUseVertexBufferObjects(bool flag)
|
||||
|
||||
void Drawable::dirtyGLObjects()
|
||||
{
|
||||
unsigned int i;
|
||||
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
for(i=0;i<_globjList.size();++i)
|
||||
for(unsigned int i=0;i<_globjList.size();++i)
|
||||
{
|
||||
if (_globjList[i] != 0)
|
||||
{
|
||||
@ -446,7 +464,7 @@ void Drawable::dirtyGLObjects()
|
||||
}
|
||||
#endif
|
||||
|
||||
for(i=0; i<_vertexArrayStateList.size(); ++i)
|
||||
for(unsigned int i=0; i<_vertexArrayStateList.size(); ++i)
|
||||
{
|
||||
VertexArrayState* vas = _vertexArrayStateList[i].get();
|
||||
if (vas) vas->dirty();
|
||||
|
@ -82,10 +82,7 @@ Geometry::Geometry(const Geometry& geometry,const CopyOp& copyop):
|
||||
|
||||
Geometry::~Geometry()
|
||||
{
|
||||
// do dirty here to keep the getGLObjectSizeHint() estimate on the ball
|
||||
dirtyGLObjects();
|
||||
|
||||
// no need to delete, all automatically handled by ref_ptr :-)
|
||||
Geometry::releaseGLObjects();
|
||||
}
|
||||
|
||||
#define ARRAY_NOT_EMPTY(array) (array!=0 && array->getNumElements()!=0)
|
||||
|
Loading…
Reference in New Issue
Block a user