Resolve textvars before opening file browser.

Fixes https://gitlab.com/kicad/code/kicad/issues/6436
This commit is contained in:
Jeff Young 2022-04-18 22:44:30 +01:00
parent cc18c31cb5
commit c3bed8f6ee
2 changed files with 13 additions and 5 deletions

View File

@ -1262,10 +1262,10 @@ wxString DIALOG_PLOT_SCHEMATIC::getOutputPath()
// Build the absolute path of current output directory to preselect it in the file browser.
std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool
{
return m_parent->Schematic().ResolveTextVar( token, 0 );
};
[&]( wxString* token ) -> bool
{
return m_parent->Schematic().ResolveTextVar( token, 0 );
};
wxString path = m_outputDirectoryName->GetValue();
path = ExpandTextVars( path, &textResolver, nullptr, &Prj() );

View File

@ -461,7 +461,15 @@ void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
{
// Build the absolute path of current output directory to preselect it in the file browser.
wxString path = ExpandEnvVarSubstitutions( m_outputDirectoryName->GetValue(), &Prj() );
std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool
{
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
};
wxString path = m_outputDirectoryName->GetValue();
path = ExpandTextVars( path, &textResolver, nullptr, &Prj() );
path = ExpandEnvVarSubstitutions( path, &Prj() );
path = Prj().AbsolutePath( path );
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );