X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FMain%2Foptions.cxx;h=2263a991ca1036e874889fa688ca235b8acdff6c;hb=d279c394d739d11b0b0367dc4be220e7b0834c84;hp=bededfb71e43ed8cbbfe535954bb60a1f5d57440;hpb=ad8e6e01b305a7d33c0ce66a3ff5429bed5b8157;p=flightgear.git diff --git a/src/Main/options.cxx b/src/Main/options.cxx index bededfb71..2263a991c 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include // rint() #include @@ -530,6 +531,14 @@ parse_fov( const string& arg ) { static bool add_channel( const string& type, const string& channel_str ) { + // This check is neccessary to prevent fgviewer from segfaulting when given + // weird options. (It doesn't run the full initailization) + if(!globals->get_channel_options_list()) + { + SG_LOG(SG_GENERAL, SG_ALERT, "Option " << type << "=" << channel_str + << " ignored."); + return false; + } SG_LOG(SG_GENERAL, SG_INFO, "Channel string = " << channel_str ); globals->get_channel_options_list()->push_back( type + "," + channel_str ); return true; @@ -1572,6 +1581,7 @@ parse_option (const string& arg) } break; case OPTION_CHANNEL: + // XXX return value of add_channel should be checked? if ( pt->has_param && !arg_value.empty() ) { add_channel( pt->option, arg_value ); } else if ( !pt->has_param && arg_value.empty() ) { @@ -1652,7 +1662,7 @@ fgParseArgs (int argc, char **argv) cout << endl << "No. Device" << endl; vector devices = smgr.get_available_devices(); - for (int i=0; i::size_type i=0; i