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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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