]> git.mxchange.org Git - flightgear.git/commitdiff
Fix a reset crash with pager threading.
authorJames Turner <zakalawe@mac.com>
Mon, 28 Mar 2016 22:50:47 +0000 (23:50 +0100)
committerJames Turner <zakalawe@mac.com>
Mon, 28 Mar 2016 22:50:47 +0000 (23:50 +0100)
Ensure pager thread is stopped before we touch
the sgUserData reference to the main props tree.

src/Main/fg_init.cxx
src/Scenery/scenery.cxx

index e7c681f485048fe9f7e3139262303bf9ca585fb7..118dd1c12a0f5a448e92f3e5f6e269e081c1f03c 100644 (file)
@@ -68,6 +68,7 @@
 #include <simgear/scene/material/Effect.hxx>
 #include <simgear/scene/model/particles.hxx>
 #include <simgear/scene/tsync/terrasync.hxx>
+#include <simgear/scene/tgdb/userdata.hxx>
 
 #include <simgear/package/Root.hxx>
 #include <simgear/package/Package.hxx>
@@ -658,6 +659,9 @@ bool fgInitGeneral() {
 
     fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );
     fgSetBool("/sim/startup/stderr-to-terminal", isatty(2) != 0 );
+
+    sgUserDataInit( globals->get_props() );
+
     return true;
 }
 
@@ -1054,7 +1058,9 @@ void fgStartNewReset()
     render->getViewer()->getDatabasePager()->clear();
     
     osgDB::Registry::instance()->clearObjectCache();
-    
+    // Pager requests depend on this, so don't clear it until now
+    sgUserDataInit( NULL );
+
     // preserve the event handler; re-creating it would entail fixing the
     // idle handler
     osg::ref_ptr<flightgear::FGEventHandler> eventHandler = render->getEventHandler();
@@ -1095,6 +1101,8 @@ void fgStartNewReset()
     render->init();
     render->setViewer(viewer.get());
 
+    sgUserDataInit( globals->get_props() );
+
     viewer->getDatabasePager()->setUpThreads(1, 1);
     
     // must do this before splashinit for Rembrandt
index 8ec3e5703b0b26b61cce4525bcbb709439508156..9b9df333fe957da80eff7f85f10a1a48b697c64d 100644 (file)
@@ -332,17 +332,12 @@ void FGScenery::init() {
     particles_branch->setName("Particles");
     scene_graph->addChild(particles_branch.get());
     simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
-
-    // Initials values needed by the draw-time object loader
-    sgUserDataInit( globals->get_props() );
   
     _listener = new ScenerySwitchListener(this);
 }
 
 void FGScenery::shutdown()
 {
-    sgUserDataInit( NULL );
-    
     scene_graph = NULL;
     terrain_branch = NULL;
     models_branch = NULL;