From 61d4a5bfbeb88fd9d6f7c3cbee465e77c034e8de Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 21 Oct 2022 08:36:27 -0700 Subject: [PATCH] Resolve embedded text vars Title Block text variables are embedded into the pcb file and should be used for resolving when the project file is missing (cherry picked from commit d1bf889e712620b220b6d4fb68f6693c4a3903a4) --- common/title_block.cpp | 8 +++++++- pcbnew/board.cpp | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/title_block.cpp b/common/title_block.cpp index 461872ef54..7c49a4862c 100644 --- a/common/title_block.cpp +++ b/common/title_block.cpp @@ -91,6 +91,7 @@ void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars ) bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) const { bool tokenUpdated = false; + wxString originalToken = *aToken; if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) ) { @@ -146,7 +147,12 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c if( tokenUpdated ) { - *aToken = ExpandTextVars( *aToken, aProject ); + *aToken = ExpandTextVars( *aToken, aProject ); + + // This is the default fallback, so don't claim we resolved it + if( *aToken == wxT( "${" ) + originalToken + wxT( "}" ) ) + return false; + return true; } diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 51cad13df7..ac6b337aeb 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -239,13 +239,15 @@ std::vector BOARD::ResolveDRCExclusions() bool BOARD::ResolveTextVar( wxString* token, int aDepth ) const { + wxString var = *token; + if( GetTitleBlock().TextVarResolver( token, m_project ) ) { return true; } - else if( m_properties.count( *token ) ) + else if( m_properties.count( var ) ) { - *token = m_properties.at( *token ); + *token = m_properties.at( var ); return true; }