From c6c4f9ae4b1e3d296dfe9eb825fbb3766b6cebe8 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 17 Feb 2022 09:09:19 -0500 Subject: [PATCH] Eeschema: fix broken symbol library rescue. Apparently at some point during V5 development, symbol cache library names were saved by replacing the LIB_ID separator character ':' with '_'. This caused the cache look up to fail there by skipping the symbol rescue which could result in broken schematics. I have no idea where this happened during V5 development. The video demo in the HEAD of the 5.1 branch shows the issue. All of the other demo cache libraries are correct. Fixes https://gitlab.com/kicad/code/kicad/-/issues/10488 --- eeschema/project_rescue.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 517da3712b..e0ecbd094e 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Chris Pavlina - * Copyright (C) 2015-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015-2022 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -89,7 +89,6 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector& aSymbol static LIB_SYMBOL* findSymbol( const wxString& aName, SYMBOL_LIBS* aLibs, bool aCached ) { LIB_SYMBOL *symbol = nullptr; - // wxString new_name = LIB_ID::FixIllegalChars( aName, false ); for( SYMBOL_LIB& each_lib : *aLibs ) { @@ -101,6 +100,17 @@ static LIB_SYMBOL* findSymbol( const wxString& aName, SYMBOL_LIBS* aLibs, bool a symbol = each_lib.FindSymbol( aName ); + // At some point during V5 development, the LIB_ID delimiter character ':' was + // replaced by '_' when writing the symbol cache library so we have to test for + // the LIB_NICKNAME_LIB_SYMBOL_NAME case. + if( symbol == nullptr && each_lib.IsCache() ) + { + wxString name = aName; + + if( name.Replace( wxT( ":" ), wxT( "_" ) ) ) + symbol = each_lib.FindSymbol( name ); + } + if( symbol ) break; }