@@ -547,6 +547,7 @@ void TextureObjectSet::handlePendingOrphandedTextureObjects()
547547 _parent->getNumberActiveTextureObjects () -= numOrphaned;
548548
549549 _pendingOrphanedTextureObjects.clear ();
550+ _pendingOrphanedTextureObjectsSize.exchange (0 );
550551
551552 CHECK_CONSISTENCY
552553}
@@ -556,6 +557,7 @@ void TextureObjectSet::deleteAllTextureObjects()
556557{
557558 // OSG_NOTICE<<"TextureObjectSet::deleteAllTextureObjects()"<<std::endl;
558559
560+ if (_pendingOrphanedTextureObjectsSize != 0 )
559561 {
560562 OpenThreads::ScopedLock<OpenThreads::Mutex> lock (_mutex);
561563 // OSG_NOTICE<<"TextureObjectSet::flushDeletedTextureObjects(..) handling orphans"<<std::endl;
@@ -619,6 +621,7 @@ void TextureObjectSet::discardAllTextureObjects()
619621 _tail = 0 ;
620622
621623 _pendingOrphanedTextureObjects.clear ();
624+ _pendingOrphanedTextureObjectsSize.exchange (0 );
622625 _orphanedTextureObjects.clear ();
623626
624627 unsigned int numDeleted = _numOfTextureObjects;
@@ -633,6 +636,7 @@ void TextureObjectSet::discardAllTextureObjects()
633636void TextureObjectSet::flushAllDeletedTextureObjects ()
634637{
635638 // OSG_NOTICE<<"TextureObjectSet::flushAllDeletedTextureObjects()"<<std::endl;
639+ if (_pendingOrphanedTextureObjectsSize != 0 )
636640 {
637641 OpenThreads::ScopedLock<OpenThreads::Mutex> lock (_mutex);
638642 // OSG_NOTICE<<"TextureObjectSet::flushDeletedTextureObjects(..) handling orphans"<<std::endl;
@@ -666,6 +670,7 @@ void TextureObjectSet::discardAllDeletedTextureObjects()
666670 // OSG_NOTICE<<"TextureObjectSet::discardAllDeletedTextureObjects()"<<std::endl;
667671
668672 // clean up the pending orphans.
673+ if (_pendingOrphanedTextureObjectsSize != 0 )
669674 {
670675 OpenThreads::ScopedLock<OpenThreads::Mutex> lock (_mutex);
671676 // OSG_NOTICE<<"TextureObjectSet::flushDeletedTextureObjects(..) handling orphans"<<std::endl;
@@ -691,6 +696,7 @@ void TextureObjectSet::flushDeletedTextureObjects(double /*currentTime*/, double
691696{
692697 // OSG_NOTICE<<"TextureObjectSet::flushDeletedTextureObjects(..)"<<std::endl;
693698
699+ if (_pendingOrphanedTextureObjectsSize != 0 )
694700 {
695701 OpenThreads::ScopedLock<OpenThreads::Mutex> lock (_mutex);
696702 // OSG_NOTICE<<"TextureObjectSet::flushDeletedTextureObjects(..) handling orphans"<<std::endl;
@@ -756,6 +762,7 @@ void TextureObjectSet::flushDeletedTextureObjects(double /*currentTime*/, double
756762
757763bool TextureObjectSet::makeSpace (unsigned int & size)
758764{
765+ if (_pendingOrphanedTextureObjectsSize != 0 )
759766 {
760767 OpenThreads::ScopedLock<OpenThreads::Mutex> lock (_mutex);
761768 // OSG_NOTICE<<"TextureObjectSet::TextureObjectSet::makeSpace(..) handling orphans"<<std::endl;
@@ -980,6 +987,7 @@ void TextureObjectSet::orphan(Texture::TextureObject* to)
980987 // list. This double buffered approach to handling orphaned TO's is used
981988 // to avoid having to mutex the process of appling active TO's.
982989 _pendingOrphanedTextureObjects.push_back (to);
990+ ++_pendingOrphanedTextureObjectsSize;
983991
984992#if 0
985993 OSG_NOTICE<<"TextureObjectSet::orphan("<<to<<") _pendingOrphanedTextureObjects.size()="<<_pendingOrphanedTextureObjects.size()<<std::endl;
0 commit comments