diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index 37f8a1d622..6b150af37e 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -160,9 +160,8 @@ wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) } else if( m_titleBlock ) { - m_titleBlock->TextVarResolver( token, m_project ); // no need for tokenUpdated; TextVarResolver() did a full resolve - return true; + return m_titleBlock->TextVarResolver( token, m_project ); } if( tokenUpdated ) diff --git a/common/title_block.cpp b/common/title_block.cpp index d48dcd6585..461872ef54 100644 --- a/common/title_block.cpp +++ b/common/title_block.cpp @@ -94,13 +94,8 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) ) { - wxString ret = GetDate(); - - if( !ret.empty() ) - { - *aToken = ret; - tokenUpdated = true; - } + *aToken = GetDate(); + tokenUpdated = true; } else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) ) { @@ -116,33 +111,18 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c } else if( aToken->IsSameAs( wxT( "REVISION" ) ) ) { - wxString ret = GetRevision(); - - if( !ret.empty() ) - { - *aToken = ret; - tokenUpdated = true; - } + *aToken = GetRevision(); + tokenUpdated = true; } else if( aToken->IsSameAs( wxT( "TITLE" ) ) ) { - wxString ret = GetTitle(); - - if( !ret.empty() ) - { - *aToken = ret; - tokenUpdated = true; - } + *aToken = GetTitle(); + tokenUpdated = true; } else if( aToken->IsSameAs( wxT( "COMPANY" ) ) ) { - wxString ret = GetCompany(); - - if( !ret.empty() ) - { - *aToken = ret; - tokenUpdated = true; - } + *aToken = GetCompany(); + tokenUpdated = true; } else if( aToken->Left( aToken->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) ) { @@ -159,13 +139,8 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c case '7': case '8': case '9': - wxString ret = GetComment( c - '1' ); - - if( !ret.empty() ) - { - *aToken = ret; - tokenUpdated = true; - } + *aToken = GetComment( c - '1' ); + tokenUpdated = true; } } diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 5be965572a..057e22753f 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -1246,7 +1246,15 @@ wxString DIALOG_PLOT_SCHEMATIC::getOutputPath() wxStandardPaths::Get().GetDocumentsDir() ); // Build the absolute path of current output directory to preselect it in the file browser. - wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() ); + std::function textResolver = + [&]( wxString* token ) -> bool + { + return m_parent->Schematic().ResolveTextVar( token, 0 ); + }; + + wxString path = m_outputDirectoryName->GetValue(); + path = ExpandTextVars( path, &textResolver, nullptr, &Prj() ); + path = ExpandEnvVarSubstitutions( path, &Prj() ); fn.SetPath( path ); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 21b00b6a5f..477a4ab6df 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -806,7 +806,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) wxString path = m_plotOpts.GetOutputDirectory(); path = ExpandTextVars( path, &textResolver, nullptr, board->GetProject() ); - path = ExpandEnvVarSubstitutions( path, nullptr ); + path = ExpandEnvVarSubstitutions( path, board->GetProject() ); wxFileName outputDir = wxFileName::DirName( path ); wxString boardFilename = m_parent->GetBoard()->GetFileName();