Avoid crash when reading a json config file having an unexpected parameter value.
Now print the json path in debug mode instead of crashing. In release mode, skip the parameter (the default value is still used) Fixes #4451 https://gitlab.com/kicad/code/kicad/issues/4451
This commit is contained in:
parent
47297402d3
commit
3f8d11144e
|
@ -67,7 +67,19 @@ JSON_SETTINGS::~JSON_SETTINGS()
|
|||
void JSON_SETTINGS::Load()
|
||||
{
|
||||
for( auto param : m_params )
|
||||
param->Load( this );
|
||||
{
|
||||
try
|
||||
{
|
||||
param->Load( this );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// Skip unreadable parameters in file:
|
||||
#ifdef DEBUG
|
||||
wxLogMessage( wxString::Format( "param '%s' load err", param->GetJsonPath().c_str() ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,14 +53,23 @@ public:
|
|||
|
||||
virtual void SetDefault() = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @return the path name of the parameter used to store it in the json file
|
||||
* mainly usefull in error messages
|
||||
*/
|
||||
const std::string& GetJsonPath() { return m_path; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* the string used to store the param in json files
|
||||
*/
|
||||
std::string m_path;
|
||||
|
||||
///! True if the parameter pointer should never be overwritten
|
||||
bool m_readOnly;
|
||||
};
|
||||
|
||||
|
||||
template<typename ValueType>
|
||||
class PARAM : public PARAM_BASE
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue