Show
Ignore:
Timestamp:
02/26/10 10:23:28 (5 years ago)
Author:
robert
Message:

From Ryan Kawicki, "I guess I missed these during my testing, but if the database pager has outstanding requests while the application is shutting down, the archive can become invalidated through unsafe calls to ReaderWriterTXP::getArchive. I've made this function return a ref_ptr and change other locations to as needed to conform to the change. I've tested this and no more crashes.

Following files from revision 11057 have been attached."

Files:
1 modified

Legend:

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

    r11037 r11122  
    5959        //the txpNode. 
    6060        int id = ++_archiveId; 
    61         TXPArchive* archive = getArchive(id,osgDB::getFilePath(fileName)); 
     61        osg::ref_ptr< TXPArchive > archive = getArchive(id,osgDB::getFilePath(fileName)); 
    6262 
    6363        if (archive != NULL) 
     
    7070            } 
    7171 
    72             txpNode->loadArchive(archive); 
    73              
     72            txpNode->loadArchive(archive.get()); 
     73 
    7474            return txpNode.get(); 
    7575        } 
     
    8686        unsigned int id; 
    8787        sscanf(name.c_str(),"tile%d_%dx%d_%u",&lod,&x,&y,&id); 
    88         TXPArchive* archive = getArchive(id,osgDB::getFilePath(file)); 
     88        osg::ref_ptr< TXPArchive > archive = getArchive(id,osgDB::getFilePath(file)); 
    8989 
    9090        // The way this is done a 'tile' should only be created for lod 0 only, 
     
    107107 
    108108        std::vector<TXPArchive::TileLocationInfo> childrenLoc; 
    109         osg::ref_ptr<osg::Node> tileContent = getTileContent(info,x,y,lod,archive, childrenLoc); 
     109        osg::ref_ptr<osg::Node> tileContent = getTileContent(info,x,y,lod,archive.get(), childrenLoc); 
    110110         
    111111        tileContent->setName("TileContent"); 
     
    199199        unsigned int id; 
    200200        sscanf(name.c_str(),"subtiles%d_%dx%d_%u",&lod,&x,&y,&id); 
    201         TXPArchive* archive = getArchive(id,osgDB::getFilePath(file)); 
     201        osg::ref_ptr< TXPArchive > archive = getArchive(id,osgDB::getFilePath(file)); 
    202202 
    203203        int majorVersion, minorVersion; 
     
    259259                    continue; 
    260260 
    261                 osg::ref_ptr<osg::Node> tileContent = getTileContent(info, loc, archive, childrenChildLoc); 
     261                osg::ref_ptr<osg::Node> tileContent = getTileContent(info, loc, archive.get(), childrenChildLoc); 
    262262 
    263263                tileContent->setName("TileContent"); 
     
    361361                    continue; 
    362362 
    363                     osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc); 
     363                    osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive.get(), childrenLoc); 
    364364 
    365365                    tileContent->setName("TileContent"); 
     
    564564} 
    565565 
    566 TXPArchive *ReaderWriterTXP::getArchive(int id, const std::string& dir) 
    567 { 
    568     TXPArchive* archive = NULL; 
     566osg::ref_ptr< TXPArchive > ReaderWriterTXP::getArchive(int id, const std::string& dir) 
     567{ 
     568    osg::ref_ptr< TXPArchive > archive = NULL; 
    569569 
    570570    std::map< int,osg::ref_ptr<TXPArchive> >::iterator iter = _archives.find(id);