Refactor exit code, so the osgViewer gets 'done'.
This commit is contained in:
parent
582c1e8df8
commit
84b45683fc
9 changed files with 20 additions and 37 deletions
|
@ -241,6 +241,8 @@ int main ( int argc, char **argv ) {
|
|||
fgviewerMain(argc, argv);
|
||||
else
|
||||
fgMainInit(argc, argv);
|
||||
|
||||
|
||||
} catch (const sg_throwable &t) {
|
||||
// We must use cerr rather than
|
||||
// logging, since logging may be
|
||||
|
|
|
@ -211,7 +211,8 @@ do_exit (const SGPropertyNode * arg)
|
|||
SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
|
||||
}
|
||||
}
|
||||
fgExit(arg->getIntValue("status", 0));
|
||||
|
||||
fgOSExit(arg->getIntValue("status", 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ enum { KEYMOD_NONE = 0,
|
|||
void fgOSInit(int* argc, char** argv);
|
||||
void fgOSOpenWindow(bool stencil);
|
||||
void fgOSFullScreen();
|
||||
void fgOSMainLoop();
|
||||
int fgOSMainLoop();
|
||||
void fgOSExit(int code);
|
||||
|
||||
void fgSetMouseCursor(int cursor);
|
||||
|
|
|
@ -271,7 +271,7 @@ void fgOSExit(int code)
|
|||
status = code;
|
||||
}
|
||||
|
||||
void fgOSMainLoop()
|
||||
int fgOSMainLoop()
|
||||
{
|
||||
ref_ptr<FGEventHandler> manipulator
|
||||
= globals->get_renderer()->getEventHandler();
|
||||
|
@ -287,7 +287,8 @@ void fgOSMainLoop()
|
|||
(*drawFunc)();
|
||||
viewer->frame();
|
||||
}
|
||||
fgExit(status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int fgGetKeyModifiers()
|
||||
|
|
|
@ -576,7 +576,7 @@ static void upper_case_property(const char *name)
|
|||
|
||||
|
||||
// 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 );
|
||||
|
@ -660,11 +660,14 @@ bool fgMainInit( int argc, char **argv ) {
|
|||
fgSplashInit();
|
||||
|
||||
// pass control off to the master event handler
|
||||
fgOSMainLoop();
|
||||
int result = fgOSMainLoop();
|
||||
|
||||
// we never actually get here ... but to avoid compiler warnings,
|
||||
// etc.
|
||||
return false;
|
||||
// clean up here; ensure we null globals to avoid
|
||||
// confusing the atexit() handler
|
||||
delete globals;
|
||||
globals = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
void fgUpdateTimeDepCalcs();
|
||||
|
||||
bool fgMainInit( int argc, char **argv );
|
||||
int fgMainInit( int argc, char **argv );
|
||||
|
||||
|
||||
extern int idle_state;
|
||||
|
|
|
@ -105,19 +105,6 @@ fgSetupWind (double min_hdg, double max_hdg, double speed, double gust)
|
|||
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)
|
||||
|
|
|
@ -49,17 +49,6 @@ extern void fgDefaultWeatherValue (const char * propname, double value);
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/fg_os.hxx>
|
||||
#include <Main/util.hxx>
|
||||
|
||||
#include "generic.hxx"
|
||||
|
||||
|
||||
|
@ -490,7 +490,7 @@ bool FGGeneric::process() {
|
|||
return true;
|
||||
error_out:
|
||||
if (exitOnError) {
|
||||
fgExit(1);
|
||||
fgOSExit(1);
|
||||
return true; // should not get there, but please the compiler
|
||||
} else
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue