]> git.mxchange.org Git - flightgear.git/commitdiff
Refactor exit code, so the osgViewer gets 'done'.
authorJames Turner <zakalawe@mac.com>
Wed, 29 Sep 2010 20:04:11 +0000 (21:04 +0100)
committerJames Turner <zakalawe@mac.com>
Thu, 30 Sep 2010 22:13:11 +0000 (23:13 +0100)
src/Main/bootstrap.cxx
src/Main/fg_commands.cxx
src/Main/fg_os.hxx
src/Main/fg_os_osgviewer.cxx
src/Main/main.cxx
src/Main/main.hxx
src/Main/util.cxx
src/Main/util.hxx
src/Network/generic.cxx

index 8a360206e533ad8d67bc298b94a6c44705bb5ebc..fb95b8f194a0acfb03a386e45b247ec3131f39a2 100644 (file)
@@ -241,6 +241,8 @@ int main ( int argc, char **argv ) {
             fgviewerMain(argc, argv);
         else
             fgMainInit(argc, argv);
+            
+        
     } catch (const sg_throwable &t) {
                             // We must use cerr rather than
                             // logging, since logging may be
index 354a92bc0fe25aa1cd21ab59e76b07bfb1da433b..1fe2c4ce464f801e235750e8c242162d08cdd135 100644 (file)
@@ -211,7 +211,8 @@ do_exit (const SGPropertyNode * arg)
             SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
         }
     }
-    fgExit(arg->getIntValue("status", 0));
+    
+    fgOSExit(arg->getIntValue("status", 0));
     return true;
 }
 
index 62f6f8f7ddc89029b73432fa4af5733f4c47896e..ebeb0701b4ed0f686ab274d76a4fb2b0086f6e42 100644 (file)
@@ -60,7 +60,7 @@ enum { KEYMOD_NONE     = 0,
 void fgOSInit(int* argc, char** argv);
 void fgOSOpenWindow(bool stencil);
 void fgOSFullScreen();
-void fgOSMainLoop();
+int fgOSMainLoop();
 void fgOSExit(int code);
 
 void fgSetMouseCursor(int cursor);
index a03cc747e859f7645853947f08b473e8d201f2cd..726c868a9ab7e721470ed1045e42676e77ca927e 100644 (file)
@@ -271,7 +271,7 @@ void fgOSExit(int code)
     status = code;
 }
 
-void fgOSMainLoop()
+int fgOSMainLoop()
 {
     ref_ptr<FGEventHandler> manipulator
         = globals->get_renderer()->getEventHandler();
@@ -287,7 +287,8 @@ void fgOSMainLoop()
             (*drawFunc)();
         viewer->frame();
     }
-    fgExit(status);
+    
+    return status;
 }
 
 int fgGetKeyModifiers()
index 894dd0010e38f19f459a331c5cec737d95c9ef91..b9c0f194f0c164689f79fd7fa6019d02b042e7f2 100644 (file)
@@ -576,7 +576,7 @@ static void upper_case_property(const char *name)
 
 
 // Main top level initialization
-bool fgMainInit( int argc, char **argv ) {
+int fgMainInit( int argc, char **argv ) {
 
     // set default log levels
     sglog().setLogLevels( SG_ALL, SG_ALERT );
@@ -660,11 +660,14 @@ bool fgMainInit( int argc, char **argv ) {
     fgSplashInit();
 
     // pass control off to the master event handler
-    fgOSMainLoop();
-
-    // we never actually get here ... but to avoid compiler warnings,
-    // etc.
-    return false;
+    int result = fgOSMainLoop();
+    
+    // clean up here; ensure we null globals to avoid
+    // confusing the atexit() handler
+    delete globals;
+    globals = NULL;
+    
+    return result;
 }
 
 
index 2117f605b9cd2f6f7291a413f9e2457bbca3ee3a..115b3c628f8a9df9a38f90c86339db9df65ad6df 100644 (file)
@@ -4,7 +4,7 @@
 
 void fgUpdateTimeDepCalcs();
 
-bool fgMainInit( int argc, char **argv );
+int fgMainInit( int argc, char **argv );
 
 
 extern int idle_state;
index 0986e91ea47a71c93b9595c25affa837743abc22..7c20530a36e5b59e6e92c0611ac00c2b5ed439cf 100644 (file)
@@ -105,19 +105,6 @@ fgSetupWind (double min_hdg, double max_hdg, double speed, double gust)
               speed);
 }
 
-
-void
-fgExit (int status)
-{
-#ifdef OSG_LIBRARY_STATIC
-    osgDB::Registry::instance( true);
-#endif
-
-    SG_LOG(SG_GENERAL, SG_INFO, "Exiting FlightGear with status " << status);
-    std::exit(status);
-}
-
-
 // Originally written by Alex Perry.
 double
 fgGetLowPass (double current, double target, double timeratio)
index 70067d3e34dcc8eb2dcca6191053137c119b3796..dcd75b1306605e9f5daf4db6b930302b74f36d58 100644 (file)
@@ -49,17 +49,6 @@ extern void fgDefaultWeatherValue (const char * propname, double value);
 extern void fgSetupWind (double min_hdg, double max_hdg,
                          double speed, double gust);
 
-/**
- * Clean up and exit FlightGear.
- *
- * This function makes sure that network connections and I/O streams
- * are cleaned up.
- *
- * @param status The exit status to pass to the operating system.
- */
-extern void fgExit (int status = 0);
-
-
 /**
  * Move a value towards a target.
  *
index 423d2be189b28ffec2de641415dc99ab3b1bdcfb..034a94fa69e7d8645beb6452b93c71b4eb388837 100644 (file)
@@ -37,8 +37,8 @@
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
+#include <Main/fg_os.hxx>
 #include <Main/util.hxx>
-
 #include "generic.hxx"
 
 
@@ -490,7 +490,7 @@ bool FGGeneric::process() {
     return true;
 error_out:
     if (exitOnError) {
-        fgExit(1);
+        fgOSExit(1);
         return true; // should not get there, but please the compiler
     } else
         return false;