diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index 5e00da7fc..1b8c97678 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -27,7 +27,11 @@ #include #include -// #define CHECK_CONSISTENCY +#if 0 + #define CHECK_CONSISTENCY checkConsistency(); +#else + #define CHECK_CONSISTENCY +#endif using namespace osg; @@ -424,10 +428,7 @@ GLBufferObjectSet::~GLBufferObjectSet() bool GLBufferObjectSet::checkConsistency() const { -#ifndef CHECK_CONSISTENCY - return true; -#else - // OSG_NOTICE<<"GLBufferObjectSet::checkConsistency()"<_previous = "<_previous<_next = "<_next< lock(_mutex); + if (!_pendingOrphanedGLBufferObjects.empty()) + { + // OSG_NOTICE<<"GLBufferObjectSet::flushDeletedGLBufferObjects(..) handling orphans"<_next; _orphanedGLBufferObjects.push_back(glbo.get()); + remove(glbo.get()); + ++numOrphaned; + ref_ptr original_BufferObject = glbo->getBufferObject(); if (original_BufferObject.valid()) { @@ -529,8 +536,8 @@ void GLBufferObjectSet::deleteAllGLBufferObjects() } } - _head = 0; - _tail = 0; + _parent->getNumberOrphanedGLBufferObjects() += numOrphaned; + _parent->getNumberActiveGLBufferObjects() -= numOrphaned; // do the actual delete. flushAllDeletedGLBufferObjects(); @@ -865,7 +872,7 @@ void GLBufferObjectSet::moveToBack(GLBufferObject* to) OSG_NOTICE<<" m2B after to->_previous = "<_previous<_next = "<_next<_previous = "<_previous<_next = "<_next<checkConsistency(); + return true; -#endif } void Texture::TextureObjectSet::handlePendingOrphandedTextureObjects() @@ -241,14 +242,6 @@ void Texture::TextureObjectSet::handlePendingOrphandedTextureObjects() _orphanedTextureObjects.push_back(to); remove(to); - -#if 0 - OSG_NOTICE<<" HPOTO after _head = "<<_head<_previous = "<_previous<_next = "<_next< lock(_mutex); + if (!_pendingOrphanedTextureObjects.empty()) + { + // OSG_NOTICE<<"Texture::TextureObjectSet::flushDeletedTextureObjects(..) handling orphans"<_previous = "<_previous<_next = "<_next<_previous = "<_previous<_next = "<_next<