From: James Turner Date: Thu, 8 Sep 2016 10:41:40 +0000 (+0100) Subject: Launcher sets —no-default-config automatically. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2a68847e31bc54d532114124a32d5e71c8df51ae;p=flightgear.git Launcher sets —no-default-config automatically. --- diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 9e658617d..d6a89fab5 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -482,6 +482,18 @@ int fgMainInit( int argc, char **argv ) upper_case_property("/sim/tower/airport-id"); upper_case_property("/autopilot/route-manager/input"); +// check if the launcher is reuested, since it affects config file parsing + bool showLauncher = flightgear::Options::checkForArg(argc, argv, "launcher"); + // an Info.plist bundle can't define command line arguments, but it can set + // environment variables. This avoids needed a wrapper shell-script on OS-X. + showLauncher |= (::getenv("FG_LAUNCHER") != 0); + if (showLauncher) { + // to minimise strange interactions when launcher and config files + // set overlaping options, we disable the default files. Users can + // still explicitly request config files via --config options if they choose. + flightgear::Options::sharedInstance()->setShouldLoadDefaultConfig(false); + } + // Load the configuration parameters. (Command line options // override config file options. Config file options override // defaults.) @@ -493,11 +505,6 @@ int fgMainInit( int argc, char **argv ) } #if defined(HAVE_QT) - bool showLauncher = flightgear::Options::checkForArg(argc, argv, "launcher"); - // an Info.plist bundle can't define command line arguments, but it can set - // environment variables. This avoids needed a wrapper shell-script on OS-X. - showLauncher |= (::getenv("FG_LAUNCHER") != 0); - if (showLauncher) { flightgear::initApp(argc, argv); if (!flightgear::runLauncherDialog()) { diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 6bfbbb7b7..26eec7838 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2628,6 +2628,11 @@ bool Options::shouldLoadDefaultConfig() const return p->shouldLoadDefaultConfig; } +void Options::setShouldLoadDefaultConfig(bool load) +{ + p->shouldLoadDefaultConfig = load; +} + bool Options::checkForArg(int argc, char* argv[], const char* checkArg) { for (int i = 0; i < argc; ++i) { diff --git a/src/Main/options.hxx b/src/Main/options.hxx index 60a59d971..e680f26d1 100644 --- a/src/Main/options.hxx +++ b/src/Main/options.hxx @@ -128,13 +128,19 @@ public: /** * should defualt configuration files be loaded and processed or not? * There's many configuration files we have historically read by default - * on startup - preferences.xml, fgfs.rc in various places and so on. + * on startup - fgfs.rc in various places and so on. * --no-default-config allows this behaviour to be changed, so only - * expicitly listed files are read - this is useful for testing. Expose + * expicitly listed files are read Expose * the value of the option here. */ bool shouldLoadDefaultConfig() const; + /** + * when using the built-in launcher, we disable the default config files. + * explicitly loaded confg files are still permitted. + */ + void setShouldLoadDefaultConfig(bool load); + /** * check if the arguments array contains a particular string (with a '--' or * '-' prefix).