Fix duplicate symbol value fields when importing Eagle schematic.

Don't use the value field when adding Eagle part attributes to a symbol.
This issue was cause by using a mandatory symbol field ID instead of
using the next available field ID when adding new fields to as symbol.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13468
This commit is contained in:
Wayne Stambaugh 2023-02-04 12:37:24 -05:00
parent 729be64850
commit 52b07b8bac
1 changed files with 13 additions and 4 deletions

View File

@ -1717,10 +1717,19 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode )
for( const auto& a : epart->attribute ) for( const auto& a : epart->attribute )
{ {
SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) ); VECTOR2I newFieldPosition( 0, 0 );
field->SetName( a.first ); SCH_FIELD* lastField = symbol->GetFieldById( symbol->GetFieldCount() - 1 );
field->SetText( a.second );
field->SetVisible( false ); if( lastField )
newFieldPosition = lastField->GetPosition();
SCH_FIELD newField( newFieldPosition, symbol->GetFieldCount(), symbol.get() );
newField.SetName( a.first );
newField.SetText( a.second );
newField.SetVisible( false );
symbol->AddField( newField );
} }
for( const auto& a : epart->variant ) for( const auto& a : epart->variant )