Name any unnamed fields so they don't clobber each other.

Fixes https://gitlab.com/kicad/code/kicad/issues/10039
This commit is contained in:
Jeff Young 2022-03-22 10:04:24 +00:00
parent 21144481d2
commit 8eb10c41d8
4 changed files with 21 additions and 8 deletions

View File

@ -209,8 +209,7 @@ public:
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i ) for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
{ {
SCH_SYMBOL* symbol = m_symbolsList[ i ].GetSymbol(); SCH_SYMBOL* symbol = m_symbolsList[ i ].GetSymbol();
m_dataStore[ symbol->m_Uuid ][ aFieldName ] = symbol->GetFieldText( aFieldName, m_dataStore[ symbol->m_Uuid ][ aFieldName ] = symbol->GetFieldText( aFieldName );
m_frame );
} }
} }

View File

@ -1117,10 +1117,10 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
switch( j - i ) switch( j - i )
{ {
case 0: bezier->SetStart( pos ); break; case 0: bezier->SetStart( pos ); break;
case 1: bezier->SetBezierC1( pos ); break; case 1: bezier->SetBezierC1( pos ); break;
case 2: bezier->SetBezierC2( pos ); break; case 2: bezier->SetBezierC2( pos ); break;
case 3: bezier->SetEnd( pos ); break; case 3: bezier->SetEnd( pos ); break;
default: break; // Can't get here but silence warnings default: break; // Can't get here but silence warnings
} }
} }
@ -2342,16 +2342,30 @@ void SCH_ALTIUM_PLUGIN::ParseParameter( const std::map<wxString, wxString>& aPro
SCH_SYMBOL* symbol = m_symbols.at( libSymbolIt->first ); SCH_SYMBOL* symbol = m_symbols.at( libSymbolIt->first );
SCH_FIELD* field = nullptr; SCH_FIELD* field = nullptr;
wxString upperName = elem.name.Upper();
if( elem.name.Upper() == "COMMENT" ) if( upperName == "COMMENT" )
{
field = symbol->GetField( VALUE_FIELD ); field = symbol->GetField( VALUE_FIELD );
}
else else
{ {
int fieldIdx = symbol->GetFieldCount(); int fieldIdx = symbol->GetFieldCount();
wxString fieldName = elem.name.Upper(); wxString fieldName = elem.name.Upper();
if( fieldName == "VALUE" ) if( fieldName.IsEmpty() )
{
int disambiguate = 1;
do
{
fieldName = wxString::Format( "ALTIUM_UNNAMED_%d", disambiguate++ );
} while( !symbol->GetFieldText( fieldName ).IsEmpty() );
}
else if( fieldName == "VALUE" )
{
fieldName = "ALTIUM_VALUE"; fieldName = "ALTIUM_VALUE";
}
field = symbol->AddField( SCH_FIELD( VECTOR2I(), fieldIdx, symbol, fieldName ) ); field = symbol->AddField( SCH_FIELD( VECTOR2I(), fieldIdx, symbol, fieldName ) );
} }

View File

@ -708,7 +708,7 @@ SCH_FIELD* SCH_SYMBOL::GetFieldById( int aFieldId )
} }
wxString SCH_SYMBOL::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame ) const wxString SCH_SYMBOL::GetFieldText( const wxString& aFieldName ) const
{ {
for( const SCH_FIELD& field : m_fields ) for( const SCH_FIELD& field : m_fields )
{ {

View File

@ -353,7 +353,7 @@ public:
* *
* @param aFieldName is the name of the field * @param aFieldName is the name of the field
*/ */
wxString GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame ) const; wxString GetFieldText( const wxString& aFieldName ) const;
/** /**
* Populate a std::vector with SCH_FIELDs. * Populate a std::vector with SCH_FIELDs.