Handle nested text variable references in title block.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16919
This commit is contained in:
Jeff Young 2024-02-09 12:37:01 +00:00
parent 91e15634fc
commit 33d93b79a3
1 changed files with 17 additions and 3 deletions

View File

@ -115,7 +115,7 @@ void DS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
{
std::function<bool( wxString* )> wsResolver =
[ this ]( wxString* token ) -> bool
[&]( wxString* token ) -> bool
{
bool tokenUpdated = false;
@ -173,10 +173,24 @@ wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
}
else if( m_titleBlock )
{
// no need for tokenUpdated; TITLE_BLOCK::TextVarResolver() does a full
// resolve
if( m_titleBlock->TextVarResolver( token, m_project ) )
{
// No need for tokenUpdated; TITLE_BLOCK::TextVarResolver() already goes
// up to the project.
//
// However, the title block may have variables in it itself, so we need
// to run the worksheet resolver again.
//
const TITLE_BLOCK* savedTitleBlock = m_titleBlock;
m_titleBlock = nullptr;
{
*token = ExpandTextVars( *token, &wsResolver );
}
m_titleBlock = savedTitleBlock;
return true;
}
}
else if( m_properties && m_properties->count( *token ) )
{