Resolve textvars in plot directory.

Fixes https://gitlab.com/kicad/code/kicad/issues/10405
This commit is contained in:
Jeff Young
2022-01-23 18:14:07 +00:00
parent f3a583e490
commit e5d5ee07f0
5 changed files with 87 additions and 22 deletions
+17 -6
View File
@@ -796,12 +796,23 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
return;
}
// Create output directory if it does not exist (also transform it in
// absolute form). Bail if it fails
wxString path = ExpandEnvVarSubstitutions( m_plotOpts.GetOutputDirectory(), &Prj() );
wxFileName outputDir = wxFileName::DirName( path );
wxString boardFilename = m_parent->GetBoard()->GetFileName();
REPORTER& reporter = m_messagesPanel->Reporter();
// Create output directory if it does not exist (also transform it in absolute form).
// Bail if it fails.
std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool
{
// Handles board->GetTitleBlock() *and* board->GetProject()
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
};
wxString path = m_plotOpts.GetOutputDirectory();
path = ExpandTextVars( path, &textResolver, nullptr, nullptr );
path = ExpandEnvVarSubstitutions( path, nullptr );
wxFileName outputDir = wxFileName::DirName( path );
wxString boardFilename = m_parent->GetBoard()->GetFileName();
REPORTER& reporter = m_messagesPanel->Reporter();
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
{