diff --git a/src/osgPlugins/txp/ReaderWriterTXP.cpp b/src/osgPlugins/txp/ReaderWriterTXP.cpp index 59511e3e8..041c59480 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.cpp +++ b/src/osgPlugins/txp/ReaderWriterTXP.cpp @@ -624,6 +624,12 @@ TXPArchive *ReaderWriterTXP::getArchive(int id, const std::string& dir) return archive; } +bool ReaderWriterTXP::removeArchive( int id ) +{ + osg::notify(osg::INFO)<<"ReaderWriterTXP::removeArchive(id="<= 1); +} + class SeamFinder: public osg::NodeVisitor { public: diff --git a/src/osgPlugins/txp/ReaderWriterTXP.h b/src/osgPlugins/txp/ReaderWriterTXP.h index 0dfa362c9..e50409d74 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.h +++ b/src/osgPlugins/txp/ReaderWriterTXP.h @@ -73,6 +73,8 @@ public: return const_cast(this)->local_readNode(file, options); } + + bool removeArchive( int id ); protected: diff --git a/src/osgPlugins/txp/TXPNode.cpp b/src/osgPlugins/txp/TXPNode.cpp index 0e3fc4f49..313b433a9 100644 --- a/src/osgPlugins/txp/TXPNode.cpp +++ b/src/osgPlugins/txp/TXPNode.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include @@ -13,7 +15,7 @@ #include "TileMapper.h" #include "TXPNode.h" #include "TXPPagedLOD.h" - +#include "ReaderWriterTXP.h" using namespace txp; @@ -78,6 +80,22 @@ _originY(txpNode._originY) TXPNode::~TXPNode() { + if (_archive.get()) + { + if (osgDB::ReaderWriter * rw = + osgDB::Registry::instance()->getReaderWriterForExtension("txp")) + { + if (ReaderWriterTXP * rwTXP = + dynamic_cast< ReaderWriterTXP * >(rw)) + { + const int id = _archive->getId(); + if (!rwTXP->removeArchive(id)) + { + TXPNodeERROR("Failed to remove archive ") << id << std::endl; + } + } + } + } } TXPArchive* TXPNode::getArchive()