Eeschema, eeschema_config.cpp: fix incorrect *.wks file path when trying to save it.

And add tests to see if the file can be saved
Fix also an issue in sch_editor_control.cpp: The page setup dlg must generate changes
only if the OK button is clicked.
Fixes #13599
https://gitlab.com/kicad/code/kicad/issues/13599
This commit is contained in:
jean-pierre charras 2023-01-22 13:17:05 +01:00
parent e900e472ce
commit 9c12a6ee1d
2 changed files with 13 additions and 9 deletions

View File

@ -130,22 +130,26 @@ void SCH_EDIT_FRAME::SaveProjectSettings()
RecordERCExclusions();
// Save the page layout file if doesn't exist yet (e.g. if we opened a non-kicad schematic)
// TODO: We need to remove dependence on BASE_SCREEN
Prj().GetProjectFile().m_SchematicSettings->m_SchDrawingSheetFileName = BASE_SCREEN::m_DrawingSheetFileName;
Prj().GetProjectFile().m_SchematicSettings->m_SchDrawingSheetFileName
= BASE_SCREEN::m_DrawingSheetFileName;
if( !BASE_SCREEN::m_DrawingSheetFileName.IsEmpty() )
{
// Save the page layout file if doesn't exist yet (e.g. if we opened a non-kicad schematic)
wxFileName layoutfn( BASE_SCREEN::m_DrawingSheetFileName );
if( !layoutfn.IsAbsolute() )
layoutfn = wxFileName( Prj().GetProjectPath(), BASE_SCREEN::m_DrawingSheetFileName );
bool success = true;
if( !layoutfn.FileExists() )
if( !layoutfn.IsAbsolute() )
success = layoutfn.MakeAbsolute( Prj().GetProjectPath() );
if( success && layoutfn.IsOk() && !layoutfn.FileExists() )
{
layoutfn.MakeAbsolute();
DS_DATA_MODEL::GetTheInstance().Save( layoutfn.GetFullPath() );
if( layoutfn.DirExists() && layoutfn.IsDirWritable() )
DS_DATA_MODEL::GetTheInstance().Save( layoutfn.GetFullPath() );
}
}

View File

@ -182,7 +182,7 @@ int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
MAX_PAGE_SIZE_EESCHEMA_MILS ) );
dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
if( dlg.ShowModal() )
if( dlg.ShowModal() == wxID_OK )
{
// Update text variables
m_frame->GetCanvas()->GetView()->MarkDirty();