fgviewerMain(argc, argv);
else
fgMainInit(argc, argv);
+
+
} catch (const sg_throwable &t) {
// We must use cerr rather than
// logging, since logging may be
SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
}
}
- fgExit(arg->getIntValue("status", 0));
+
+ fgOSExit(arg->getIntValue("status", 0));
return true;
}
void fgOSInit(int* argc, char** argv);
void fgOSOpenWindow(bool stencil);
void fgOSFullScreen();
-void fgOSMainLoop();
+int fgOSMainLoop();
void fgOSExit(int code);
void fgSetMouseCursor(int cursor);
status = code;
}
-void fgOSMainLoop()
+int fgOSMainLoop()
{
ref_ptr<FGEventHandler> manipulator
= globals->get_renderer()->getEventHandler();
(*drawFunc)();
viewer->frame();
}
- fgExit(status);
+
+ return status;
}
int fgGetKeyModifiers()
// 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 );
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;
}
void fgUpdateTimeDepCalcs();
-bool fgMainInit( int argc, char **argv );
+int fgMainInit( int argc, char **argv );
extern int idle_state;
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)
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.
*
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
+#include <Main/fg_os.hxx>
#include <Main/util.hxx>
-
#include "generic.hxx"
return true;
error_out:
if (exitOnError) {
- fgExit(1);
+ fgOSExit(1);
return true; // should not get there, but please the compiler
} else
return false;