Skip to content

Commit

Permalink
Properly initialize members of options_manager::cOpt
Browse files Browse the repository at this point in the history
Specifically initialize members that get used when serializing the option value (which triggers printing the default value, so we need a valid one).
  • Loading branch information
BevapDin committed Jan 11, 2020
1 parent 57b7dbe commit f13a987
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,32 @@ void options_manager::add_external( const std::string &sNameIn, const std::strin
thisOpt.sMenuText = sMenuTextIn;
thisOpt.sTooltip = sTooltipIn;
thisOpt.sType = sType;
thisOpt.verbose = false;

thisOpt.eType = get_value_type( thisOpt.sType );

thisOpt.iMin = INT_MIN;
thisOpt.iMax = INT_MAX;

thisOpt.fMin = INT_MIN;
thisOpt.fMax = INT_MAX;
switch( thisOpt.eType ) {
case cOpt::CVT_BOOL:
thisOpt.bSet = false;
thisOpt.bDefault = false;
break;
case cOpt::CVT_INT:
thisOpt.iMin = INT_MIN;
thisOpt.iMax = INT_MAX;
thisOpt.iDefault = 0;
thisOpt.iSet = 0;
break;
case cOpt::CVT_FLOAT:
thisOpt.fMin = INT_MIN;
thisOpt.fMax = INT_MAX;
thisOpt.fDefault = 0;
thisOpt.fSet = 0;
thisOpt.fStep = 1;
break;
default:
// all other type-specific values have default constructors
break;
}

thisOpt.hide = COPT_ALWAYS_HIDE;
thisOpt.setSortPos( sPageIn );
Expand Down

0 comments on commit f13a987

Please sign in to comment.