1
0
Fork 0

Register an atexit() function so we can delete the global constructor.

This also gives us a proper hook if we want to clean up SDL (Andy?)
This commit is contained in:
curt 2004-04-25 02:06:55 +00:00
parent 3816f4fbb4
commit 2f1e2bc6e9
5 changed files with 32 additions and 13 deletions

View 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;
}

View 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;

View 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 );

View 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;
}

View file

@ -484,6 +484,7 @@ FGProps::open()
bool
FGProps::close()
{
SG_LOG( SG_IO, SG_INFO, "closing FGProps" );
return true;
}