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:
parent
de0826294c
commit
4a485adcf3
4 changed files with 12 additions and 5 deletions
|
@ -717,7 +717,9 @@ void fgInitAircraftPaths(bool reinit)
|
||||||
int fgInitAircraft(bool reinit)
|
int fgInitAircraft(bool reinit)
|
||||||
{
|
{
|
||||||
if (!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());
|
FindAndCacheAircraft f(globals->get_props());
|
||||||
|
|
|
@ -647,7 +647,9 @@ int fgMainInit( int argc, char **argv )
|
||||||
configResult = fgInitAircraft(false);
|
configResult = fgInitAircraft(false);
|
||||||
if (configResult == flightgear::FG_OPTIONS_ERROR) {
|
if (configResult == flightgear::FG_OPTIONS_ERROR) {
|
||||||
return EXIT_FAILURE;
|
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;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2211,7 +2211,7 @@ void Options::initPaths()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::initAircraft()
|
OptionResult Options::initAircraft()
|
||||||
{
|
{
|
||||||
string aircraft;
|
string aircraft;
|
||||||
if (isOptionSet("aircraft")) {
|
if (isOptionSet("aircraft")) {
|
||||||
|
@ -2246,7 +2246,8 @@ void Options::initAircraft()
|
||||||
aircraft_paths.end());
|
aircraft_paths.end());
|
||||||
|
|
||||||
fgShowAircraft(path_list);
|
fgShowAircraft(path_list);
|
||||||
exit(0);
|
// this is to indicate that we did show it
|
||||||
|
return FG_OPTIONS_SHOW_AIRCRAFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOptionSet("aircraft-dir")) {
|
if (isOptionSet("aircraft-dir")) {
|
||||||
|
@ -2268,6 +2269,8 @@ void Options::initAircraft()
|
||||||
// can't validate this until the -set.xml is parsed
|
// can't validate this until the -set.xml is parsed
|
||||||
fgSetString("/sim/aircraft-state", stateName);
|
fgSetString("/sim/aircraft-state", stateName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return FG_OPTIONS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::processArgResult(int result)
|
void Options::processArgResult(int result)
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* init the aircraft options
|
* init the aircraft options
|
||||||
*/
|
*/
|
||||||
void initAircraft();
|
OptionResult initAircraft();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* should defualt configuration files be loaded and processed or not?
|
* should defualt configuration files be loaded and processed or not?
|
||||||
|
|
Loading…
Reference in a new issue