Duplicate field names not allowed - throw exception on load
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16902
This commit is contained in:
parent
f3566a987d
commit
9f20816b24
|
@ -790,6 +790,15 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
|
|||
CurOffset() );
|
||||
}
|
||||
|
||||
if( LIB_FIELD* existingName = aSymbol->FindField( name ) )
|
||||
{
|
||||
if( existingName->GetId() > MANDATORY_FIELDS )
|
||||
{
|
||||
THROW_PARSE_ERROR( wxString::Format( _( "Duplicate field '%s'" ), name ),
|
||||
CurSource(), CurLine(), CurLineNumber(), CurOffset() );
|
||||
}
|
||||
}
|
||||
|
||||
field->SetName( name );
|
||||
|
||||
// Correctly set the ID based on canonical (untranslated) field name
|
||||
|
|
|
@ -669,7 +669,19 @@ void SCH_LEGACY_PLUGIN_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol,
|
|||
}
|
||||
else
|
||||
{
|
||||
parseQuotedString( field->m_name, aReader, line, &line, true ); // Optional.
|
||||
wxString fieldName = wxEmptyString;
|
||||
parseQuotedString( fieldName, aReader, line, &line, true ); // Optional.
|
||||
|
||||
if( fieldName.IsEmpty() )
|
||||
return;
|
||||
|
||||
if( aSymbol->FindField( fieldName ) != nullptr )
|
||||
{
|
||||
SCH_PARSE_ERROR( wxString::Format( _( "Duplicate field '%s'" ), fieldName ),
|
||||
aReader, line );
|
||||
}
|
||||
|
||||
field->m_name = fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue