Try harder not to give a read-only path to save dialog

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5937
This commit is contained in:
Jon Evans 2020-10-21 20:55:43 -04:00
parent 35c7ba0a8a
commit 2153a7655b
2 changed files with 23 additions and 5 deletions

View File

@ -57,6 +57,7 @@
#include <widgets/infobar.h> #include <widgets/infobar.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <page_layout/ws_data_model.h> #include <page_layout/ws_data_model.h>
#include <wx/stdpaths.h>
bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName ) bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
{ {
@ -80,10 +81,18 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
if( aSaveUnderNewName ) if( aSaveUnderNewName )
{ {
wxString wildcards = KiCadSchematicFileWildcard(); wxFileName savePath( Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Schematic Files" ), wxPathOnly( Prj().GetProjectFullName() ), if( !savePath.IsOk() || !savePath.IsDirWritable() )
schematicFileName.GetFullName(), wildcards, {
savePath = GetMruPath();
if( !savePath.IsOk() || !savePath.IsDirWritable() )
savePath = wxStandardPaths::Get().GetDocumentsDir();
}
wxFileDialog dlg( this, _( "Schematic Files" ), savePath.GetPath(),
schematicFileName.GetFullName(), KiCadSchematicFileWildcard(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )

View File

@ -395,8 +395,17 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
orig_name = _( "noname" ); orig_name = _( "noname" );
} }
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); wxFileName savePath( Prj().GetProjectFullName() );
wxFileName fn( pro_dir, orig_name, KiCadPcbFileExtension );
if( !savePath.IsOk() || !savePath.IsDirWritable() )
{
savePath = GetMruPath();
if( !savePath.IsOk() || !savePath.IsDirWritable() )
savePath = wxStandardPaths::Get().GetDocumentsDir();
}
wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
wxString filename = fn.GetFullPath(); wxString filename = fn.GetFullPath();
bool createProject = false; bool createProject = false;