]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_init.cxx
Reset, fix Nasal timers added on shutdown.
[flightgear.git] / src / Main / fg_init.cxx
index 070d4daf38b68bc57e3f909dfdaaf0be5fc3d9b2..3abb334601472843151010de39fdc7721254706f 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
@@ -941,19 +941,24 @@ void fgStartNewReset()
 {
     SGPropertyNode_ptr preserved(new SGPropertyNode);
     
-    // copy properties which are USERARCHIVEd or PRESERVEd
-    int checked = SGPropertyNode::USERARCHIVE+SGPropertyNode::PRESERVE;
-    if (!copyProperties(globals->get_props(), preserved, checked, checked))
+    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);
     
     SGSubsystemMgr* subsystemManger = globals->get_subsystem_mgr();
+    // Nasal is manually inited in fgPostInit, ensure it's already shutdown
+    // before other subsystems, so Nasal listeners don't fire during shutdonw
+    SGSubsystem* nasal = subsystemManger->get_subsystem("nasal");
+    nasal->shutdown();
+    nasal->unbind();
+    subsystemManger->remove("nasal");
+    
     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());
@@ -1002,12 +1007,13 @@ void fgStartNewReset()
     simgear::clearEffectCache();
     simgear::SGModelLib::resetPropertyRoot();
         
-    globals->resetPropertyRoot();
+    simgear::GlobalParticleCallback::setSwitch(NULL);
     
+    globals->resetPropertyRoot();
     fgInitConfig(0, NULL, true);
     fgInitGeneral(); // all of this?
     
-    if ( copyProperties(preserved, globals->get_props(), checked, checked)) {
+    if ( copyProperties(preserved, globals->get_props()) {
         SG_LOG( SG_GENERAL, SG_INFO, "Preserved state restored successfully" );
     } else {
         SG_LOG( SG_GENERAL, SG_INFO,
@@ -1023,14 +1029,15 @@ void fgStartNewReset()
     globals->set_renderer(render);
     render->init();
     render->setViewer(viewer.get());
+
     viewer->getDatabasePager()->setUpThreads(1, 1);
-    render->splashinit();
     
+    // must do this before splashinit for Rembrandt
     flightgear::CameraGroup::buildDefaultGroup(viewer.get());
-
+    render->splashinit();
+    
     fgOSResetProperties();
 
-    
 // init some things manually
 // which do not follow the regular init pattern