]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/main.cxx
Provide debug information on thread safety of osg::Referenced.
[flightgear.git] / src / Main / main.cxx
index 175058073e191e5519f74c52a6b3f9d91d3c9293..47817c6f1bdb2febcecc8365e40912763fbf95a8 100644 (file)
@@ -65,6 +65,7 @@
 #include "fg_props.hxx"
 #include "positioninit.hxx"
 #include "subsystemFactory.hxx"
+#include "options.hxx"
 
 using namespace flightgear;
 
@@ -84,9 +85,6 @@ static void fgMainLoop( void )
 {
     frame_signal->fireValueChanged();
 
-    SG_LOG( SG_GENERAL, SG_DEBUG, "Running Main Loop");
-    SG_LOG( SG_GENERAL, SG_DEBUG, "======= ==== ====");
-
     // compute simulated time (allowing for pause, warp, etc) and
     // real elapsed time
     double sim_dt, real_dt;
@@ -96,8 +94,6 @@ static void fgMainLoop( void )
     globals->get_subsystem_mgr()->update(sim_dt);
 
     simgear::AtomicChangeListener::fireChangeListeners();
-
-    SG_LOG( SG_GENERAL, SG_DEBUG, "" );
 }
 
 
@@ -132,7 +128,7 @@ static void fgIdleFunction ( void ) {
     } else if ( idle_state == 2 ) {
         
         // start TerraSync up now, so it can be synchronizing shared models
-        // and airports data in parallel with a nav-cahce rebuild. 
+        // and airports data in parallel with a nav-cache rebuild.
         SGPath tsyncCache(globals->get_fg_home());
         tsyncCache.append("terrasync-cache.xml");
         fgSetString("/sim/terrasync/cache-path", tsyncCache.c_str());
@@ -140,9 +136,15 @@ static void fgIdleFunction ( void ) {
         simgear::SGTerraSync* terra_sync = new simgear::SGTerraSync(globals->get_props());
         globals->add_subsystem("terrasync", terra_sync);
         
+        
+        
         terra_sync->bind();
         terra_sync->init();
         
+        // add the terrasync root as a data path so data can be retrieved from it
+        std::string terraSyncDir(fgGetString("/sim/terrasync/scenery-dir"));
+        globals->append_data_path(terraSyncDir);
+        
         idle_state++;
         fgSplashProgress("loading-nav-dat");
 
@@ -169,9 +171,7 @@ static void fgIdleFunction ( void ) {
         
         // Do some quick general initializations
         if( !fgInitGeneral()) {
-            SG_LOG( SG_GENERAL, SG_ALERT,
-                "General initialization failed ..." );
-            exit(-1);
+            throw sg_exception("General initialization failed");
         }
 
         ////////////////////////////////////////////////////////////////////
@@ -328,6 +328,12 @@ int fgMainInit( int argc, char **argv ) {
     SG_LOG( SG_GENERAL, SG_INFO, "FlightGear:  Version "
             << version );
     SG_LOG( SG_GENERAL, SG_INFO, "Built with " << SG_COMPILER_STR << std::endl );
+    SG_LOG( SG_GL,
+            SG_INFO,
+            "osg::Referenced thread safe reference counting is "
+            << (osg::Referenced::getThreadSafeReferenceCounting() ? "enabled"
+                                                                  : "disabled")
+          );
 
     // Allocate global data structures.  This needs to happen before
     // we parse command line options
@@ -349,11 +355,13 @@ int fgMainInit( int argc, char **argv ) {
     // Load the configuration parameters.  (Command line options
     // override config file options.  Config file options override
     // defaults.)
-    if ( !fgInitConfig(argc, argv) ) {
-      SG_LOG( SG_GENERAL, SG_ALERT, "Config option parsing failed ..." );
-      exit(-1);
+    int configResult = fgInitConfig(argc, argv);
+    if (configResult == flightgear::FG_OPTIONS_ERROR) {
+        return EXIT_FAILURE;
+    } else if (configResult == flightgear::FG_OPTIONS_EXIT) {
+        return EXIT_SUCCESS;
     }
-
+    
     // Initialize the Window/Graphics environment.
     fgOSInit(&argc, argv);
     _bootstrap_OSInit++;