Altium: Don't create duplicate fields
This commit is contained in:
parent
1a6e6a06eb
commit
420413969e
|
@ -3813,25 +3813,26 @@ void SCH_IO_ALTIUM::ParseLibParameter( const std::map<wxString, wxString>& aProp
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int fieldIdx = libSymbol->GetFieldCount();
|
int fieldIdx = libSymbol->GetFieldCount();
|
||||||
wxString fieldName = elem.name.Upper();
|
wxString fieldNameStem = elem.name;
|
||||||
|
wxString fieldName = fieldNameStem;
|
||||||
|
int disambiguate = 1;
|
||||||
|
|
||||||
if( fieldName.IsEmpty() )
|
if( fieldName.IsEmpty() )
|
||||||
{
|
{
|
||||||
int disambiguate = 1;
|
fieldNameStem = "ALTIUM_UNNAMED";
|
||||||
|
fieldName = "ALTIUM_UNNAMED_1";
|
||||||
while( 1 )
|
disambiguate = 2;
|
||||||
{
|
|
||||||
fieldName = wxString::Format( "ALTIUM_UNNAMED_%d", disambiguate++ );
|
|
||||||
|
|
||||||
if( !libSymbol->FindField( fieldName ) )
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else if( upperName == "VALUE" )
|
||||||
else if( fieldName == "VALUE" )
|
|
||||||
{
|
{
|
||||||
|
fieldNameStem = "ALTIUM_VALUE";
|
||||||
fieldName = "ALTIUM_VALUE";
|
fieldName = "ALTIUM_VALUE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid adding duplicate fields
|
||||||
|
while( libSymbol->FindField( fieldName ) )
|
||||||
|
fieldName = wxString::Format( "%s_%d", fieldNameStem, disambiguate++ );
|
||||||
|
|
||||||
LIB_FIELD* new_field = new LIB_FIELD( fieldIdx, fieldName );
|
LIB_FIELD* new_field = new LIB_FIELD( fieldIdx, fieldName );
|
||||||
libSymbol->AddField( new_field );
|
libSymbol->AddField( new_field );
|
||||||
field = new_field;
|
field = new_field;
|
||||||
|
|
Loading…
Reference in New Issue