From 7b19fb0c8dc13ff0a1bf670245e0b4ffb5e1e2f1 Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Mon, 6 May 2024 12:15:14 -0400 Subject: [PATCH] Legacy Libraries: fix Description field clobbering user field Fixes: https://gitlab.com/kicad/code/kicad/-/issues/17943 --- .../sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp index 92871cf22d..c009e9311a 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp @@ -539,7 +539,9 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField( std::unique_ptr& 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& aSym } else { + id = aSymbol->GetNextAvailableFieldId(); field = new LIB_FIELD( aSymbol.get(), id ); aSymbol->AddDrawItem( field, false ); }