1
0
Fork 0

Fix crash on —show-aircraft

Change how we return, so QApplication doesn’t explode. exit() is not
a happy thing for QApplication.

Ticket:
https://sourceforge.net/p/flightgear/codetickets/2139/
This commit is contained in:
James Turner 2020-04-29 14:55:37 +01:00
parent de0826294c
commit 4a485adcf3
4 changed files with 12 additions and 5 deletions

View file

@ -717,7 +717,9 @@ void fgInitAircraftPaths(bool reinit)
int fgInitAircraft(bool reinit)
{
if (!reinit) {
flightgear::Options::sharedInstance()->initAircraft();
auto r = flightgear::Options::sharedInstance()->initAircraft();
if (r == flightgear::FG_OPTIONS_SHOW_AIRCRAFT)
return r;
}
FindAndCacheAircraft f(globals->get_props());

View file

@ -647,7 +647,9 @@ int fgMainInit( int argc, char **argv )
configResult = fgInitAircraft(false);
if (configResult == flightgear::FG_OPTIONS_ERROR) {
return EXIT_FAILURE;
} else if (configResult == flightgear::FG_OPTIONS_EXIT) {
} else if ((configResult == flightgear::FG_OPTIONS_EXIT) ||
(configResult == flightgear::FG_OPTIONS_SHOW_AIRCRAFT))
{
return EXIT_SUCCESS;
}

View file

@ -2211,7 +2211,7 @@ void Options::initPaths()
}
void Options::initAircraft()
OptionResult Options::initAircraft()
{
string aircraft;
if (isOptionSet("aircraft")) {
@ -2246,7 +2246,8 @@ void Options::initAircraft()
aircraft_paths.end());
fgShowAircraft(path_list);
exit(0);
// this is to indicate that we did show it
return FG_OPTIONS_SHOW_AIRCRAFT;
}
if (isOptionSet("aircraft-dir")) {
@ -2268,6 +2269,8 @@ void Options::initAircraft()
// can't validate this until the -set.xml is parsed
fgSetString("/sim/aircraft-state", stateName);
}
return FG_OPTIONS_OK;
}
void Options::processArgResult(int result)

View file

@ -130,7 +130,7 @@ public:
/**
* init the aircraft options
*/
void initAircraft();
OptionResult initAircraft();
/**
* should defualt configuration files be loaded and processed or not?