Changeset 11037

Show
Ignore:
Timestamp:
02/02/10 12:16:10 (4 years ago)
Author:
robert
Message:

From Ryan Kawicki, added removal of TXPArchive from ReaderWriterTXP when the TXPNode destructs to fix memory consumption issue relating to leaving unused archives in memory.

Location:
OpenSceneGraph/trunk/src/osgPlugins/txp
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.cpp

    r11036 r11037  
    625625} 
    626626 
     627bool ReaderWriterTXP::removeArchive( int id ) 
     628{ 
     629    osg::notify(osg::INFO)<<"ReaderWriterTXP::removeArchive(id="<<id<<")"<<std::endl; 
     630    return (_archives.erase(id) >= 1); 
     631} 
     632 
    627633class SeamFinder: public osg::NodeVisitor 
    628634{ 
  • OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.h

    r8578 r11037  
    7474        return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options); 
    7575    } 
     76 
     77    bool removeArchive( int id ); 
    7678     
    7779protected: 
  • OpenSceneGraph/trunk/src/osgPlugins/txp/TXPNode.cpp

    r10965 r11037  
    55#include <osg/MatrixTransform> 
    66#include <osgUtil/CullVisitor> 
     7#include <osgDB/Registry> 
     8#include <osgDB/ReaderWriter> 
    79 
    810#include <iostream> 
     
    1416#include "TXPNode.h" 
    1517#include "TXPPagedLOD.h" 
    16  
     18#include "ReaderWriterTXP.h" 
    1719 
    1820 
     
    7981TXPNode::~TXPNode() 
    8082{ 
     83   if (_archive.get()) 
     84   { 
     85      if (osgDB::ReaderWriter * rw = 
     86          osgDB::Registry::instance()->getReaderWriterForExtension("txp")) 
     87      { 
     88         if (ReaderWriterTXP * rwTXP = 
     89             dynamic_cast< ReaderWriterTXP * >(rw)) 
     90         { 
     91            const int id = _archive->getId(); 
     92            if (!rwTXP->removeArchive(id)) 
     93            { 
     94               TXPNodeERROR("Failed to remove archive ") << id << std::endl; 
     95            } 
     96         } 
     97      } 
     98   } 
    8199} 
    82100