From ade29c85775d51c0153ce542a5ef8f7fdb16c57d Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Fri, 10 Mar 2023 09:16:05 -0500 Subject: [PATCH] Schematic Sheet Variables: more SCH_SHEET_PATH plumbing Fixes: https://gitlab.com/kicad/code/kicad/-/issues/14239 --- eeschema/sch_sheet.cpp | 6 +++--- eeschema/sch_sheet.h | 6 +++++- eeschema/sch_symbol.cpp | 2 +- eeschema/sch_text.cpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index a0a0fc44cd..18052dbff8 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -234,7 +234,7 @@ void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const } -bool SCH_SHEET::ResolveTextVar( wxString* token, int aDepth ) const +bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const { if( !Schematic() ) return false; @@ -291,13 +291,13 @@ bool SCH_SHEET::ResolveTextVar( wxString* token, int aDepth ) const // See if parent can resolve it (these will recurse to ancestors) - SCH_SHEET_PATH sheetPath = findSelf(); + SCH_SHEET_PATH sheetPath = aPath ? *aPath : findSelf(); if( sheetPath.size() >= 2 ) { sheetPath.pop_back(); - if( sheetPath.Last()->ResolveTextVar( token, aDepth + 1 ) ) + if( sheetPath.Last()->ResolveTextVar( aPath, token, aDepth + 1 ) ) return true; } else diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 4617574b40..56dffd7445 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -153,7 +153,11 @@ public: * * @param aDepth is a counter to limit recursion and circular references. */ - bool ResolveTextVar( wxString* token, int aDepth = 0 ) const; + bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const; + bool ResolveTextVar( wxString* token, int aDepth = 0 ) + { + return ResolveTextVar( nullptr, token, aDepth ); + } void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index e7473da2e2..42807707fb 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1313,7 +1313,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA if( sheet ) { - if( sheet->ResolveTextVar( token, aDepth + 1 ) ) + if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) ) return true; } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 6e0dc9e982..2f9ea9db15 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -353,7 +353,7 @@ wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, bool a { if( sheet ) { - if( sheet->ResolveTextVar( token, aDepth + 1 ) ) + if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) ) return true; }