From a416eb2cf66f60a24e712afed0d6039281c6af46 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 29 Sep 2023 12:53:33 -0400 Subject: [PATCH] Fix schematic editor crash when updating symbols. Some how symbol names that still have escaped '/' character get mixed with symbol names that have '/' characters now that it is no longer an invalid LIB_ID character. This was causing derived symbols to loose the link to the parent symbol. This fix replaces any instances of "{slash}" with "/" to convert symbol names to the proper escaping. Thanks to JP for the inspiration for the fix. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15715 Manually cherry picked from commit 2f51d22b3a1b9409e5e335ab79a6999a454dc49a. --- eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 07e4e661ba..22060765fd 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -192,6 +192,11 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF name = FromUTF8(); + // Some symbol LIB_IDs have the '/' character escaped which can break derived symbol links. + // The '/' character is no longer an illegal LIB_ID character so it doesn't need to be + // escaped. + name.Replace( wxS( "{slash}" ), wxT( "/" ) ); + LIB_ID id; int bad_pos = id.Parse( name ); @@ -268,6 +273,12 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF } name = FromUTF8(); + + // Some symbol LIB_IDs have the '/' character escaped which can break derived + // symbol links. The '/' character is no longer an illegal LIB_ID character so + // it doesn't need to be escaped. + name.Replace( wxS( "{slash}" ), wxT( "/" ) ); + auto it = aSymbolLibMap.find( name ); if( it == aSymbolLibMap.end() ) @@ -293,6 +304,11 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF name = FromUTF8(); + // Some symbol LIB_IDs have the '/' character escaped which can break derived + // symbol links. The '/' character is no longer an illegal LIB_ID character so + // it doesn't need to be escaped. + name.Replace( wxS( "{slash}" ), wxT( "/" ) ); + if( !name.StartsWith( m_symbolName ) ) { error.Printf( _( "Invalid symbol unit name prefix %s" ), name.c_str() );