sim_model: Fix another not handled exception that fully freeze Eeschema.

Can happens with schematics with old sim parameter syntax.
Fix also another crash in sim_model.
This commit is contained in:
jean-pierre charras 2022-12-14 17:47:20 +01:00
parent ce6378fed3
commit cdcf875ec0
1 changed files with 24 additions and 3 deletions

View File

@ -492,7 +492,15 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel, unsig
{
std::unique_ptr<SIM_MODEL> model = Create( aBaseModel.GetType() );
model->SetBaseModel( aBaseModel );
try
{
model->SetBaseModel( aBaseModel );
}
catch( IO_ERROR& err )
{
DisplayErrorMessage( nullptr, err.What() );
}
model->ReadDataFields( aSymbolPinCount, static_cast<const std::vector<void>*>( nullptr ) );
return model;
}
@ -510,7 +518,14 @@ std::unique_ptr<SIM_MODEL> SIM_MODEL::Create( const SIM_MODEL& aBaseModel, unsig
std::unique_ptr<SIM_MODEL> model = Create( type );
model->SetBaseModel( aBaseModel );
try
{
model->SetBaseModel( aBaseModel );
}
catch( IO_ERROR& err )
{
DisplayErrorMessage( nullptr, err.What() );
}
model->ReadDataFields( aSymbolPinCount, &aFields );
return model;
}
@ -1306,7 +1321,13 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
aSymbol.AddField( paramsField );
if( modelFromValueField )
valueField->SetText( wxT( "${SIM.PARAMS}" ) );
{
// Get the current Value field, after previous changes.
valueField = aSymbol.FindField( wxT( "Value" ) );
if( valueField )
valueField->SetText( wxT( "${SIM.PARAMS}" ) );
}
}
if( !pinMap.IsEmpty() )