Don't add duplicate SIM fields.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17970
This commit is contained in:
parent
7aa3892ba3
commit
a20a6e0787
|
@ -204,6 +204,19 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto getOrCreateField =
|
||||||
|
[&aSymbol, &fields]( const wxString& name ) -> SCH_FIELD*
|
||||||
|
{
|
||||||
|
for( SCH_FIELD& field : fields )
|
||||||
|
{
|
||||||
|
if( field.GetName().IsSameAs( name ) )
|
||||||
|
return &field;
|
||||||
|
}
|
||||||
|
|
||||||
|
fields.emplace_back( &aSymbol, -1, name );
|
||||||
|
return &fields.back();
|
||||||
|
};
|
||||||
|
|
||||||
wxString deviceType;
|
wxString deviceType;
|
||||||
wxString modelType;
|
wxString modelType;
|
||||||
wxString modelParams;
|
wxString modelParams;
|
||||||
|
@ -214,20 +227,13 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
|
||||||
if( SIM_MODEL::InferSimModel( aSymbol, &fields, true, SIM_VALUE_GRAMMAR::NOTATION::SI,
|
if( SIM_MODEL::InferSimModel( aSymbol, &fields, true, SIM_VALUE_GRAMMAR::NOTATION::SI,
|
||||||
&deviceType, &modelType, &modelParams, &pinMap ) )
|
&deviceType, &modelType, &modelParams, &pinMap ) )
|
||||||
{
|
{
|
||||||
fields.emplace_back( &aSymbol, -1, SIM_DEVICE_FIELD );
|
getOrCreateField( SIM_DEVICE_FIELD )->SetText( deviceType );
|
||||||
fields.back().SetText( deviceType );
|
|
||||||
|
|
||||||
if( !modelType.IsEmpty() )
|
if( !modelType.IsEmpty() )
|
||||||
{
|
getOrCreateField( SIM_DEVICE_SUBTYPE_FIELD )->SetText( modelType );
|
||||||
fields.emplace_back( &aSymbol, -1, SIM_DEVICE_SUBTYPE_FIELD );
|
|
||||||
fields.back().SetText( modelType );
|
|
||||||
}
|
|
||||||
|
|
||||||
fields.emplace_back( &aSymbol, -1, SIM_PARAMS_FIELD );
|
getOrCreateField( SIM_PARAMS_FIELD )->SetText( modelParams );
|
||||||
fields.back().SetText( modelParams );
|
getOrCreateField( SIM_PINS_FIELD )->SetText( pinMap );
|
||||||
|
|
||||||
fields.emplace_back( &aSymbol, -1, SIM_PINS_FIELD );
|
|
||||||
fields.back().SetText( pinMap );
|
|
||||||
|
|
||||||
storeInValue = true;
|
storeInValue = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1508,6 +1508,8 @@ void SIM_MODEL::MigrateSimModel( T& aSymbol, const PROJECT* aProject )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Up until 8.0.3 we
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue