diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 4f3120f90..5a97e20b2 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -39,6 +39,7 @@ #include // atof(), atoi() #include // strcmp() #include +#include #include #include @@ -2020,7 +2021,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath) continue; } - int result = parseOption(argv[i]); + int result = parseOption(argv[i], /* fromConfigFile */ false); processArgResult(result); } else { // XML properties file @@ -2231,7 +2232,7 @@ void Options::readConfig(const SGPath& path) break; line = line.substr( 0, i ); - if ( parseOption( line ) == FG_OPTIONS_ERROR ) { + if ( parseOption(line, /* fromConfigFile */ true) == FG_OPTIONS_ERROR ) { cerr << endl << "Config file parse error: " << path << " '" << line << "'" << endl; p->showHelp = true; @@ -2242,7 +2243,7 @@ void Options::readConfig(const SGPath& path) p->insertGroupMarker(); // each config file is a group } -int Options::parseOption(const string& s) +int Options::parseOption(const string& s, bool fromConfigFile) { if ((s == "--help") || (s=="-h")) { return FG_OPTIONS_HELP; @@ -2276,7 +2277,15 @@ int Options::parseOption(const string& s) SGPath path = s.substr(9); if (path.extension() == "xml") { p->propertyFiles.push_back(path); - } else { + } else if (fromConfigFile) { + flightgear::fatalMessageBoxThenExit( + "FlightGear", + "Invalid use of the --config option.", + "Sorry, it is currently not supported to load a configuration file " + "using --config from another configuration file.\n\n" + "Note: this does not apply to loading of XML PropertyList files " + "with --config."); + } else { // the --config option comes from the command line p->configFiles.push_back(path); } diff --git a/src/Main/options.hxx b/src/Main/options.hxx index ad8d848bf..ee3434a99 100644 --- a/src/Main/options.hxx +++ b/src/Main/options.hxx @@ -171,8 +171,10 @@ private: // paths, etc. to stdout in JSON format, using the UTF-8 encoding. void printJSONReport() const; - int parseOption(const std::string& s); - + // The 'fromConfigFile' parameter indicates whether the option comes from a + // config file or directly from the command line. + int parseOption(const std::string& s, bool fromConfigFile); + void processArgResult(int result); /**