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 0f3d14df38
commit 1db236c7fd
1 changed files with 4 additions and 1 deletions

View File

@ -542,7 +542,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
SCH_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 );
@ -553,6 +555,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr<LIB_SYMBOL>& aSym
}
else
{
id = aSymbol->GetNextAvailableFieldId();
field = new SCH_FIELD( aSymbol.get(), id );
aSymbol->AddDrawItem( field, false );
}