//
// Written by Curtis Olson, started May 1997.
//
-// Copyright (C) 1997 - 2002 Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1997 - 2002 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
#endif
#include <stdlib.h>
+#include <stdio.h>
#include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
SG_USING_STD(endl);
#include "main.hxx"
+#include "globals.hxx"
#ifdef HAVE_WINDOWS_H
# include <console.h> // -dw- for command line dialog
#endif
+// foreward declaration.
+void fgExitCleanup();
#if defined(__linux__) && defined(__i386__)
}
#endif
+int _bootstrap_OSInit;
+
// Main entry point; catch any exceptions that have made it this far.
int main ( int argc, char **argv ) {
+ _bootstrap_OSInit = 0;
+
// Enable floating-point exceptions for Linux/x86
#if defined(__linux__) && defined(__i386__)
initFPE();
PSN psn;
fgOSInit (&argc, argv);
+ _bootstrap_OSInit++;
CPSGetCurrentProcess(&psn);
CPSSetProcessName(&psn, "FlightGear");
// FIXME: add other, more specific
// exceptions.
try {
+ atexit(fgExitCleanup);
fgMainInit(argc, argv);
} catch (sg_throwable &t) {
// We must use cerr rather than
// disabled.
cerr << "Fatal error: " << t.getFormattedMessage()
<< "\n (received from " << t.getOrigin() << ')' << endl;
- exit(1);
+ } catch (...) {
+ cerr << "Unknown exception in the main loop. Aborting..." << endl;
+ perror("Possible cause");
}
return 0;
}
+// do some clean up on exit. Specifically we want to call alutExit()
+// which happens in the sound manager destructor.
+void fgExitCleanup() {
+
+ if (_bootstrap_OSInit != 0)
+ fgSetMouseCursor(MOUSE_CURSOR_POINTER);
+
+ if (globals)
+ delete globals;
+}