]> git.mxchange.org Git - flightgear.git/commitdiff
Fix crash on exit (cancel the osgDB pager)
authorJames Turner <zakalawe@mac.com>
Mon, 30 Dec 2013 15:23:01 +0000 (15:23 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 30 Dec 2013 15:24:15 +0000 (15:24 +0000)
- borrow some code from the new reset codepath to cleanly stop the
OSG pager thread during normal shutdown. Avoids a race-condition
destroying various structures the pager thread might be modifying.

src/Main/globals.cxx

index c083f326f965b631906ea49f8a280c3571a8e8ca..9c714f6cb266c2548a989ea0f79b87f371eebf9e 100644 (file)
@@ -27,6 +27,9 @@
 #include <boost/foreach.hpp>
 #include <algorithm>
 
+#include <osgViewer/Viewer>
+#include <osgDB/Registry>
+
 #include <simgear/structure/commands.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/sg_dir.hxx>
@@ -209,6 +212,12 @@ FGGlobals::~FGGlobals()
     subsystem_mgr->remove("model-manager");
     _tile_mgr.clear();
 
+    // don't cancel the pager until after shutdown, since AIModels (and
+    // potentially others) can queue delete requests on the pager.
+    renderer->getViewer()->getDatabasePager()->cancel();
+    renderer->getViewer()->getDatabasePager()->clear();
+    osgDB::Registry::instance()->clearObjectCache();
+    
     // renderer touches subsystems during its destruction
     set_renderer(NULL);
     _scenery.clear();