Fix expand variables for built-in
Allow falling back to the alternate variable definitions if the built-in text block variables are not set. Also push the project into variable resolution when plotting Fixes https://gitlab.com/kicad/code/kicad/issues/11168
This commit is contained in:
parent
d801a8689c
commit
c44d31fcfb
|
@ -94,8 +94,13 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
||||||
|
|
||||||
if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
|
if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
|
||||||
{
|
{
|
||||||
*aToken = GetDate();
|
wxString ret = GetDate();
|
||||||
tokenUpdated = true;
|
|
||||||
|
if( !ret.empty() )
|
||||||
|
{
|
||||||
|
*aToken = ret;
|
||||||
|
tokenUpdated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
else if( aToken->IsSameAs( wxT( "CURRENT_DATE" ) ) )
|
||||||
{
|
{
|
||||||
|
@ -111,18 +116,33 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
||||||
}
|
}
|
||||||
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
|
else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
|
||||||
{
|
{
|
||||||
*aToken = GetRevision();
|
wxString ret = GetRevision();
|
||||||
tokenUpdated = true;
|
|
||||||
|
if( !ret.empty() )
|
||||||
|
{
|
||||||
|
*aToken = ret;
|
||||||
|
tokenUpdated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( aToken->IsSameAs( wxT( "TITLE" ) ) )
|
else if( aToken->IsSameAs( wxT( "TITLE" ) ) )
|
||||||
{
|
{
|
||||||
*aToken = GetTitle();
|
wxString ret = GetTitle();
|
||||||
tokenUpdated = true;
|
|
||||||
|
if( !ret.empty() )
|
||||||
|
{
|
||||||
|
*aToken = ret;
|
||||||
|
tokenUpdated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( aToken->IsSameAs( wxT( "COMPANY" ) ) )
|
else if( aToken->IsSameAs( wxT( "COMPANY" ) ) )
|
||||||
{
|
{
|
||||||
*aToken = GetCompany();
|
wxString ret = GetCompany();
|
||||||
tokenUpdated = true;
|
|
||||||
|
if( !ret.empty() )
|
||||||
|
{
|
||||||
|
*aToken = ret;
|
||||||
|
tokenUpdated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( aToken->Left( aToken->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) )
|
else if( aToken->Left( aToken->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) )
|
||||||
{
|
{
|
||||||
|
@ -139,8 +159,13 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
*aToken = GetComment( c - '1' );
|
wxString ret = GetComment( c - '1' );
|
||||||
tokenUpdated = true;
|
|
||||||
|
if( !ret.empty() )
|
||||||
|
{
|
||||||
|
*aToken = ret;
|
||||||
|
tokenUpdated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -814,7 +814,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString path = m_plotOpts.GetOutputDirectory();
|
wxString path = m_plotOpts.GetOutputDirectory();
|
||||||
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
|
path = ExpandTextVars( path, &textResolver, nullptr, board->GetProject() );
|
||||||
path = ExpandEnvVarSubstitutions( path, nullptr );
|
path = ExpandEnvVarSubstitutions( path, nullptr );
|
||||||
|
|
||||||
wxFileName outputDir = wxFileName::DirName( path );
|
wxFileName outputDir = wxFileName::DirName( path );
|
||||||
|
|
Loading…
Reference in New Issue