From 1d8ed071b8efcf080e360c300b9ce3045a96d05a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 15 Jan 2025 00:07:22 +0000 Subject: [PATCH] Respect recursion depth limit. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19633 --- eeschema/sch_field.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 6efaec6cba..41d4478223 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -280,23 +280,22 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT // and labels recurse, text that is none of those types such as text // boxes and labels do not. This only loops if there is still a // variable to resolve. - for( int ii = 0; ii < 10 && text.Contains( wxT( "${" ) ); ++ii ) - { - if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth ) + for( int ii = aDepth; + ii < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth && text.Contains( wxT( "${" ) ); + ++ii ) + { + if( m_parent && m_parent->Type() == LIB_SYMBOL_T ) + text = ExpandTextVars( text, &libSymbolResolver ); + else if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) + text = ExpandTextVars( text, &symbolResolver ); + else if( m_parent && m_parent->Type() == SCH_SHEET_T ) + text = ExpandTextVars( text, &sheetResolver ); + else if( m_parent && m_parent->IsType( labelTypes ) ) + text = ExpandTextVars( text, &labelResolver ); + else if( Schematic() ) { - if( m_parent && m_parent->Type() == LIB_SYMBOL_T ) - text = ExpandTextVars( text, &libSymbolResolver ); - else if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) - text = ExpandTextVars( text, &symbolResolver ); - else if( m_parent && m_parent->Type() == SCH_SHEET_T ) - text = ExpandTextVars( text, &sheetResolver ); - else if( m_parent && m_parent->IsType( labelTypes ) ) - text = ExpandTextVars( text, &labelResolver ); - else if( Schematic() ) - { - text = ExpandTextVars( text, &Schematic()->Prj() ); - text = ExpandTextVars( text, &schematicResolver ); - } + text = ExpandTextVars( text, &Schematic()->Prj() ); + text = ExpandTextVars( text, &schematicResolver ); } }