Legacy Libraries: fix Description field clobbering user field

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/17943
This commit is contained in:
Mike Williams 2024-05-06 12:15:14 -04:00
parent f6480d67eb
commit 7b19fb0c8d
1 changed files with 4 additions and 1 deletions

View File

@ -539,7 +539,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
LIB_FIELD* field;
if( id >= 0 && id < MANDATORY_FIELDS )
// Description was not mandatory until v8.0, so any fields with an index
// past this point should be user fields
if( id >= 0 && id < DESCRIPTION_FIELD )
{
field = aSymbol->GetFieldById( id );
@ -550,6 +552,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
}
else
{
id = aSymbol->GetNextAvailableFieldId();
field = new LIB_FIELD( aSymbol.get(), id );
aSymbol->AddDrawItem( field, false );
}