diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 15397c41f..e9748c28c 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -449,7 +449,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit ) options->init(argc, argv, dataPath); } - bool loadDefaults = flightgear::Options::sharedInstance()->shouldLoadDefaultConfig(); + bool loadDefaults = options->shouldLoadDefaultConfig(); if (loadDefaults) { // Read global preferences from $FG_ROOT/preferences.xml SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences"); @@ -469,21 +469,24 @@ int fgInitConfig ( int argc, char **argv, bool reinit ) } else { SG_LOG(SG_GENERAL, SG_INFO, "not reading default configuration files"); }// of no-default-config selected - - // Scan user config files and command line for a specified aircraft. - options->initAircraft(); - - FindAndCacheAircraft f(globals->get_props()); - if (!f.loadAircraft()) { - return flightgear::FG_OPTIONS_ERROR; - } - - // parse options after loading aircraft to ensure any user - // overrides of defaults are honored. - return options->processOptions(); + + return flightgear::FG_OPTIONS_OK; } - +int fgInitAircraft(bool reinit) +{ + // Scan user config files and command line for a specified aircraft. + if (!reinit) { + flightgear::Options::sharedInstance()->initAircraft(); + } + + FindAndCacheAircraft f(globals->get_props()); + if (!f.loadAircraft()) { + return flightgear::FG_OPTIONS_ERROR; + } + + return flightgear::FG_OPTIONS_OK; +} /** * Initialize vor/ndb/ils/fix list management and query systems (as @@ -987,6 +990,10 @@ void fgStartNewReset() fgInitConfig(0, NULL, true); fgInitGeneral(); // all of this? + fgGetNode("/sim")->removeChild("aircraft-dir"); + fgInitAircraft(true); + flightgear::Options::sharedInstance()->processOptions(); + render = new FGRenderer; render->setEventHandler(eventHandler); globals->set_renderer(render); @@ -998,6 +1005,7 @@ void fgStartNewReset() flightgear::CameraGroup::buildDefaultGroup(viewer.get()); fgOSResetProperties(); + // init some things manually // which do not follow the regular init pattern diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index b0399099a..beefcbea8 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -39,6 +39,7 @@ bool fgInitHome(); // Read in configuration (file and command line) int fgInitConfig ( int argc, char **argv, bool reinit ); +int fgInitAircraft(bool reinit); // log various settings / configuration state void fgOutputSettings(); diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 2fda3045b..c666b5459 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -146,7 +146,7 @@ FGGlobals::FGGlobals() : ATIS_mgr( NULL ), controls( NULL ), viewmgr( NULL ), - commands( SGCommandMgr::instance() ), + commands( new SGCommandMgr ), channel_options_list( NULL ), initial_waypoints( NULL ), fontcache ( new FGFontCache ), @@ -230,6 +230,8 @@ FGGlobals::~FGGlobals() locale = NULL; props.clear(); + + delete commands; } // set the fg_root path diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 26701f8a0..8b7083470 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -388,6 +388,20 @@ int fgMainInit( int argc, char **argv ) { return EXIT_SUCCESS; } + configResult = fgInitAircraft(false); + if (configResult == flightgear::FG_OPTIONS_ERROR) { + return EXIT_FAILURE; + } else if (configResult == flightgear::FG_OPTIONS_EXIT) { + return EXIT_SUCCESS; + } + + configResult = flightgear::Options::sharedInstance()->processOptions(); + if (configResult == flightgear::FG_OPTIONS_ERROR) { + return EXIT_FAILURE; + } else if (configResult == flightgear::FG_OPTIONS_EXIT) { + return EXIT_SUCCESS; + } + // Initialize the Window/Graphics environment. fgOSInit(&argc, argv); _bootstrap_OSInit++;