]> git.mxchange.org Git - flightgear.git/commitdiff
Register an atexit() function so we can delete the global constructor.
authorcurt <curt>
Sun, 25 Apr 2004 02:06:55 +0000 (02:06 +0000)
committercurt <curt>
Sun, 25 Apr 2004 02:06:55 +0000 (02:06 +0000)
This also gives us a proper hook if we want to clean up SDL (Andy?)

src/Main/globals.cxx
src/Main/main.cxx
src/Network/atlas.cxx
src/Network/httpd.cxx
src/Network/props.cxx

index b6a932760287f986a205f4b694ac3dced31d1649..d65861eee0b7e9012a286f35c8dd421360b21ec5 100644 (file)
@@ -21,6 +21,7 @@
 // $Id$
 
 
+#include <simgear/sound/soundmgr_openal.hxx>
 #include <simgear/structure/commands.hxx>
 #include <simgear/misc/sg_path.hxx>
 
@@ -71,10 +72,10 @@ FGGlobals::FGGlobals() :
     acmodel( NULL ),
     model_mgr( NULL ),
     channel_options_list( NULL ),
+    initial_waypoints(0),
     scenery( NULL ),
     tile_mgr( NULL ),
-    io( new FGIO ),
-    initial_waypoints(0)
+    io( new FGIO )
 {
 }
 
@@ -82,17 +83,18 @@ FGGlobals::FGGlobals() :
 // Destructor
 FGGlobals::~FGGlobals() 
 {
-  delete subsystem_mgr;
-  delete event_mgr;
-  delete initial_state;
-  delete props;
-  delete commands;
-  delete io;
+    delete soundmgr;
+    delete subsystem_mgr;
+    delete event_mgr;
+    delete initial_state;
+    delete props;
+    delete commands;
+    delete io;
   
-  // make sure only to delete the initial waypoints list if it acually
-  // still exists. 
-  if (initial_waypoints)
-    delete initial_waypoints;
+    // make sure only to delete the initial waypoints list if it acually
+    // still exists. 
+    if (initial_waypoints)
+        delete initial_waypoints;
 }
 
 
index 73a07e1454121931235335b963eb27ee94fc172b..3d9fc2c53214e17d6df826a75acddd98d6003137 100644 (file)
@@ -1442,6 +1442,14 @@ void fgReshape( int width, int height ) {
 
 }
 
+
+// do some clean up on exit.  Specifically we want to call alutExit()
+// which happens in the sound manager destructor.
+void fgExitCleanup() {
+    delete globals;
+}
+
+
 // Main top level initialization
 bool fgMainInit( int argc, char **argv ) {
 
@@ -1454,6 +1462,8 @@ bool fgMainInit( int argc, char **argv ) {
     // set default log levels
     sglog().setLogLevels( SG_ALL, SG_ALERT );
 
+    atexit(fgExitCleanup);
+
     string version;
 #ifdef FLIGHTGEAR_VERSION
     version = FLIGHTGEAR_VERSION;
index a31378547530262ae3c7e0fd2222865fa3aaabed..3301c55cfd7ea2b572a099c367ad569d4be5b18d 100644 (file)
@@ -568,6 +568,7 @@ bool FGAtlas::process() {
 
 // close the channel
 bool FGAtlas::close() {
+    SG_LOG( SG_IO, SG_INFO, "closing FGAtlas" );   
     SGIOChannel *io = get_io_channel();
 
     set_enabled( false );
index 5b591b99f7e3bc7ca2e49bf81969922b9e7686e1..3e4242492dd2b0d67f987ade27f4cffa12681e65 100644 (file)
@@ -74,7 +74,12 @@ bool FGHttpd::process() {
 
 
 bool FGHttpd::close() {
-    delete server;
+    SG_LOG( SG_IO, SG_INFO, "closing FGHttpd" );   
+
+    // the following delete causes a seg fault, gdb is not helpful.
+    // delete server;
+
+    set_enabled( false );
 
     return true;
 }
index 58f7e4466ce3c864cdd9281cd703b122a3523d04..3504f99c8c75115730f0a0584e6e49310d05a8f4 100644 (file)
@@ -484,6 +484,7 @@ FGProps::open()
 bool
 FGProps::close()
 {
+    SG_LOG( SG_IO, SG_INFO, "closing FGProps" );   
     return true;
 }