diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index bfc4b8af67..b89568921a 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -115,7 +115,7 @@ void DS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars ) wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) { std::function 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 ) ) {