From 52b07b8bac3021968ef410f30704993aef28b799 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 4 Feb 2023 12:37:24 -0500 Subject: [PATCH] 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 --- eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index c106778746..13af185b52 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -1717,10 +1717,19 @@ void SCH_EAGLE_PLUGIN::loadInstance( wxXmlNode* aInstanceNode ) for( const auto& a : epart->attribute ) { - SCH_FIELD* field = symbol->AddField( *symbol->GetField( VALUE_FIELD ) ); - field->SetName( a.first ); - field->SetText( a.second ); - field->SetVisible( false ); + VECTOR2I newFieldPosition( 0, 0 ); + SCH_FIELD* lastField = symbol->GetFieldById( symbol->GetFieldCount() - 1 ); + + 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 )