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 2f51d22b3a.
This commit is contained in:
Wayne Stambaugh 2023-09-29 12:53:33 -04:00
parent 2959c94bd3
commit a416eb2cf6
1 changed files with 16 additions and 0 deletions

View File

@ -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() );