Save rules file when saving project.
Fixes https://gitlab.com/kicad/code/kicad/issues/8143
This commit is contained in:
parent
9a282f081a
commit
311bb9c36e
|
@ -930,14 +930,26 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this will break if we ever go multi-board
|
// TODO: these will break if we ever go multi-board
|
||||||
wxFileName projectFile( pcbFileName );
|
wxFileName projectFile( pcbFileName );
|
||||||
|
wxFileName rulesFile( pcbFileName );
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
projectFile.SetExt( ProjectFileExtension );
|
projectFile.SetExt( ProjectFileExtension );
|
||||||
|
rulesFile.SetExt( DesignRulesFileExtension );
|
||||||
|
|
||||||
if( !projectFile.FileExists() && aChangeProject )
|
if( !projectFile.FileExists() && aChangeProject )
|
||||||
GetSettingsManager()->SaveProjectAs( projectFile.GetFullPath() );
|
GetSettingsManager()->SaveProjectAs( projectFile.GetFullPath() );
|
||||||
|
|
||||||
|
if( !rulesFile.FileExists() && aChangeProject )
|
||||||
|
KiCopyFile( GetDesignRulesPath(), rulesFile.GetFullPath(), msg );
|
||||||
|
|
||||||
|
if( !msg.IsEmpty() )
|
||||||
|
{
|
||||||
|
DisplayError( this, wxString::Format( _( "Error saving custom rules file '%s'." ),
|
||||||
|
rulesFile.GetFullPath() ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( projectFile.FileExists() )
|
if( projectFile.FileExists() )
|
||||||
{
|
{
|
||||||
// Save various DRC parameters, such as violation severities (which may have been
|
// Save various DRC parameters, such as violation severities (which may have been
|
||||||
|
@ -965,10 +977,9 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Error saving board file '%s'.\n%s" ),
|
DisplayError( this, wxString::Format( _( "Error saving board file '%s'.\n%s" ),
|
||||||
pcbFileName.GetFullPath(),
|
pcbFileName.GetFullPath(),
|
||||||
ioe.What() );
|
ioe.What() ) );
|
||||||
DisplayError( this, msg );
|
|
||||||
|
|
||||||
lowerTxt.Printf( _( "Failed to create temporary file '%s'." ), tempFile.GetFullPath() );
|
lowerTxt.Printf( _( "Failed to create temporary file '%s'." ), tempFile.GetFullPath() );
|
||||||
|
|
||||||
|
@ -983,11 +994,10 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
|
||||||
// If save succeeded, replace the original with what we just wrote
|
// If save succeeded, replace the original with what we just wrote
|
||||||
if( !wxRenameFile( tempFile.GetFullPath(), pcbFileName.GetFullPath() ) )
|
if( !wxRenameFile( tempFile.GetFullPath(), pcbFileName.GetFullPath() ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Error saving board file \"%s\".\n"
|
DisplayError( this, wxString::Format( _( "Error saving board file \"%s\".\n"
|
||||||
"Failed to rename temporary file \"%s\"" ),
|
"Failed to rename temporary file \"%s\"" ),
|
||||||
pcbFileName.GetFullPath(),
|
pcbFileName.GetFullPath(),
|
||||||
tempFile.GetFullPath() );
|
tempFile.GetFullPath() ) );
|
||||||
DisplayError( this, msg );
|
|
||||||
|
|
||||||
lowerTxt.Printf( _( "Failed to rename temporary file \"%s\"" ),
|
lowerTxt.Printf( _( "Failed to rename temporary file \"%s\"" ),
|
||||||
tempFile.GetFullPath() );
|
tempFile.GetFullPath() );
|
||||||
|
@ -1048,10 +1058,8 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject
|
||||||
|
|
||||||
if( !IsWritable( pcbFileName ) )
|
if( !IsWritable( pcbFileName ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "No access rights to write to file '%s'." ),
|
DisplayError( this, wxString::Format( _( "No access rights to write to file '%s'." ),
|
||||||
pcbFileName.GetFullPath() );
|
pcbFileName.GetFullPath() ) );
|
||||||
|
|
||||||
DisplayError( this, msg );
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,21 +1079,32 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Error saving board file '%s'.\n%s" ),
|
DisplayError( this, wxString::Format( _( "Error saving board file '%s'.\n%s" ),
|
||||||
pcbFileName.GetFullPath(),
|
pcbFileName.GetFullPath(),
|
||||||
ioe.What() );
|
ioe.What() ) );
|
||||||
DisplayError( this, msg );
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileName projectFile( pcbFileName );
|
wxFileName projectFile( pcbFileName );
|
||||||
|
wxFileName rulesFile( pcbFileName );
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
projectFile.SetExt( ProjectFileExtension );
|
projectFile.SetExt( ProjectFileExtension );
|
||||||
|
rulesFile.SetExt( DesignRulesFileExtension );
|
||||||
|
|
||||||
if( aCreateProject && !projectFile.FileExists() )
|
if( aCreateProject && !projectFile.FileExists() )
|
||||||
GetSettingsManager()->SaveProjectCopy( projectFile.GetFullPath() );
|
GetSettingsManager()->SaveProjectCopy( projectFile.GetFullPath() );
|
||||||
|
|
||||||
|
if( aCreateProject && !rulesFile.FileExists() )
|
||||||
|
KiCopyFile( GetDesignRulesPath(), rulesFile.GetFullPath(), msg );
|
||||||
|
|
||||||
|
if( !msg.IsEmpty() )
|
||||||
|
{
|
||||||
|
DisplayError( this, wxString::Format( _( "Error saving custom rules file '%s'." ),
|
||||||
|
rulesFile.GetFullPath() ) );
|
||||||
|
}
|
||||||
|
|
||||||
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n\"%s\"" ),
|
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n\"%s\"" ),
|
||||||
pcbFileName.GetFullPath() ) );
|
pcbFileName.GetFullPath() ) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue