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);
|
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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue