]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Fix for the fix: check for a viewer.
[flightgear.git] / src / Main / fg_init.cxx
index dc56fb0af50d09d2b354c2980ce3745d22a9e1be..8de7deda1962b4b6d5681467a2a487ffefe7387c 100644 (file)
@@ -436,7 +436,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
     
     simgear::Dir exportDir(simgear::Dir(dataPath).file("Export"));
     if (!exportDir.exists()) {
-      exportDir.create(0777);
+      exportDir.create(0755);
     }
     
     // Set /sim/fg-home and don't allow malign code to override it until
@@ -939,7 +939,10 @@ void fgReInitSubsystems()
 
 void fgStartNewReset()
 {
-    globals->saveInitialState();
+    SGPropertyNode_ptr preserved(new SGPropertyNode);
+    
+    if (!copyPropertiesWithAttribute(globals->get_props(), preserved, SGPropertyNode::PRESERVE))
+        SG_LOG(SG_GENERAL, SG_ALERT, "Error saving preserved state");
     
     fgSetBool("/sim/signals/reinit", true);
     fgSetBool("/sim/freeze/master", true);
@@ -948,7 +951,7 @@ void fgStartNewReset()
     subsystemManger->shutdown();
     subsystemManger->unbind();
     
-    // remove them all (with some exceptions?)
+    // remove most subsystems, with a few exceptions.
     for (int g=0; g<SGSubsystemMgr::MAX_GROUPS; ++g) {
         SGSubsystemGroup* grp = subsystemManger->get_group(static_cast<SGSubsystemMgr::GroupType>(g));
         const string_list& names(grp->member_names());
@@ -982,6 +985,7 @@ void fgStartNewReset()
     // don't cancel the pager until after shutdown, since AIModels (and
     // potentially others) can queue delete requests on the pager.
     render->getViewer()->getDatabasePager()->cancel();
+    render->getViewer()->getDatabasePager()->clear();
     
     osgDB::Registry::instance()->clearObjectCache();
     
@@ -996,13 +1000,20 @@ void fgStartNewReset()
     simgear::clearEffectCache();
     simgear::SGModelLib::resetPropertyRoot();
         
-    globals->resetPropertyRoot();
-    globals->restoreInitialState();
+    simgear::GlobalParticleCallback::setSwitch(NULL);
     
+    globals->resetPropertyRoot();
     fgInitConfig(0, NULL, true);
     fgInitGeneral(); // all of this?
     
-    fgGetNode("/sim")->removeChild("aircraft-dir");    
+    if ( copyProperties(preserved, globals->get_props()) ) {
+        SG_LOG( SG_GENERAL, SG_INFO, "Preserved state restored successfully" );
+    } else {
+        SG_LOG( SG_GENERAL, SG_INFO,
+               "Some errors restoring preserved state (read-only props?)" );
+    }
+
+    fgGetNode("/sim")->removeChild("aircraft-dir");
     fgInitAircraft(true);
     flightgear::Options::sharedInstance()->processOptions();