1
0
Fork 0

Refactor exit code, so the osgViewer gets 'done'.

This commit is contained in:
James Turner 2010-09-29 21:04:11 +01:00
parent 582c1e8df8
commit 84b45683fc
9 changed files with 20 additions and 37 deletions

View file

@ -241,6 +241,8 @@ int main ( int argc, char **argv ) {
fgviewerMain(argc, argv); fgviewerMain(argc, argv);
else else
fgMainInit(argc, argv); fgMainInit(argc, argv);
} catch (const sg_throwable &t) { } catch (const sg_throwable &t) {
// We must use cerr rather than // We must use cerr rather than
// logging, since logging may be // logging, since logging may be

View file

@ -211,7 +211,8 @@ do_exit (const SGPropertyNode * arg)
SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings"); SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
} }
} }
fgExit(arg->getIntValue("status", 0));
fgOSExit(arg->getIntValue("status", 0));
return true; return true;
} }

View file

@ -60,7 +60,7 @@ enum { KEYMOD_NONE = 0,
void fgOSInit(int* argc, char** argv); void fgOSInit(int* argc, char** argv);
void fgOSOpenWindow(bool stencil); void fgOSOpenWindow(bool stencil);
void fgOSFullScreen(); void fgOSFullScreen();
void fgOSMainLoop(); int fgOSMainLoop();
void fgOSExit(int code); void fgOSExit(int code);
void fgSetMouseCursor(int cursor); void fgSetMouseCursor(int cursor);

View file

@ -271,7 +271,7 @@ void fgOSExit(int code)
status = code; status = code;
} }
void fgOSMainLoop() int fgOSMainLoop()
{ {
ref_ptr<FGEventHandler> manipulator ref_ptr<FGEventHandler> manipulator
= globals->get_renderer()->getEventHandler(); = globals->get_renderer()->getEventHandler();
@ -287,7 +287,8 @@ void fgOSMainLoop()
(*drawFunc)(); (*drawFunc)();
viewer->frame(); viewer->frame();
} }
fgExit(status);
return status;
} }
int fgGetKeyModifiers() int fgGetKeyModifiers()

View file

@ -576,7 +576,7 @@ static void upper_case_property(const char *name)
// Main top level initialization // Main top level initialization
bool fgMainInit( int argc, char **argv ) { int fgMainInit( int argc, char **argv ) {
// set default log levels // set default log levels
sglog().setLogLevels( SG_ALL, SG_ALERT ); sglog().setLogLevels( SG_ALL, SG_ALERT );
@ -660,11 +660,14 @@ bool fgMainInit( int argc, char **argv ) {
fgSplashInit(); fgSplashInit();
// pass control off to the master event handler // pass control off to the master event handler
fgOSMainLoop(); int result = fgOSMainLoop();
// we never actually get here ... but to avoid compiler warnings, // clean up here; ensure we null globals to avoid
// etc. // confusing the atexit() handler
return false; delete globals;
globals = NULL;
return result;
} }

View file

@ -4,7 +4,7 @@
void fgUpdateTimeDepCalcs(); void fgUpdateTimeDepCalcs();
bool fgMainInit( int argc, char **argv ); int fgMainInit( int argc, char **argv );
extern int idle_state; extern int idle_state;

View file

@ -105,19 +105,6 @@ fgSetupWind (double min_hdg, double max_hdg, double speed, double gust)
speed); 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. // Originally written by Alex Perry.
double double
fgGetLowPass (double current, double target, double timeratio) fgGetLowPass (double current, double target, double timeratio)

View file

@ -49,17 +49,6 @@ extern void fgDefaultWeatherValue (const char * propname, double value);
extern void fgSetupWind (double min_hdg, double max_hdg, extern void fgSetupWind (double min_hdg, double max_hdg,
double speed, double gust); 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. * Move a value towards a target.
* *

View file

@ -37,8 +37,8 @@
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/fg_os.hxx>
#include <Main/util.hxx> #include <Main/util.hxx>
#include "generic.hxx" #include "generic.hxx"
@ -490,7 +490,7 @@ bool FGGeneric::process() {
return true; return true;
error_out: error_out:
if (exitOnError) { if (exitOnError) {
fgExit(1); fgOSExit(1);
return true; // should not get there, but please the compiler return true; // should not get there, but please the compiler
} else } else
return false; return false;