Pcbnew: Verify path can be made relative before asking in plotter dialog

CHANGED: When the output path is set in the plotter dialog, the user is
asked if they want to make the path relative to the project.  The old
code would ask the user if they wanted to do this, and then if it
failed would present an error dialog.  The new code tries it first on
a copy, and only if it works does the user get asked if they want
to do it.

Fixes https://gitlab.com/kicad/code/kicad/issues/5263
This commit is contained in:
PJM 2020-08-19 17:10:36 -07:00 committed by Wayne Stambaugh
parent de7a1b647c
commit dad3101107
1 changed files with 14 additions and 10 deletions

View File

@ -362,6 +362,13 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
wxFileName fn( Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ) );
wxString defaultPath = fn.GetPathWithSep();
wxString msg;
wxFileName relPathTest; // Used to test if we can make the path relative
relPathTest.Assign( dirDialog.GetPath() );
// Test if making the path relative is possible before asking the user if they want to do it
if( relPathTest.MakeRelativeTo( defaultPath ) )
{
msg.Printf( _( "Do you want to use a path relative to\n\"%s\"" ),
GetChars( defaultPath ) );
@ -369,10 +376,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
if( dialog.ShowModal() == wxID_YES )
{
if( !dirName.MakeRelativeTo( defaultPath ) )
wxMessageBox( _( "Cannot make path relative (target volume different from file volume)!" ),
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
dirName.MakeRelativeTo( defaultPath );
}
m_outputDirectoryName->SetValue( dirName.GetFullPath() );