Single warning for all locked sheets when saving schematic.
Also checks for modified before trying to save at all. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15946 Fixes https://gitlab.com/kicad/code/kicad/-/issues/15963
This commit is contained in:
parent
3651cad7fd
commit
8cba785375
|
@ -1009,6 +1009,10 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
|||
// File doesn't exist yet; true if we just imported something
|
||||
updateFileHistory = true;
|
||||
}
|
||||
else if( !Schematic().GetSheets().IsModified() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( filenameMap.empty() || !saveCopy )
|
||||
{
|
||||
|
@ -1018,6 +1022,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
|||
|
||||
// Warn user on potential file overwrite. This can happen on shared sheets.
|
||||
wxArrayString overwrittenFiles;
|
||||
wxArrayString lockedFiles;
|
||||
|
||||
for( size_t i = 0; i < screens.GetCount(); i++ )
|
||||
{
|
||||
|
@ -1031,6 +1036,9 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
|||
if( !tmpFn.IsOk() )
|
||||
continue;
|
||||
|
||||
if( tmpFn.FileExists() && !tmpFn.IsFileWritable() )
|
||||
lockedFiles.Add( tmpFn.GetFullPath() );
|
||||
|
||||
if( tmpFn.GetExt() == KiCadSchematicFileExtension )
|
||||
continue;
|
||||
|
||||
|
@ -1040,6 +1048,26 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
|||
overwrittenFiles.Add( tmpFn.GetFullPath() );
|
||||
}
|
||||
|
||||
if( !lockedFiles.IsEmpty() )
|
||||
{
|
||||
for( const wxString& lockedFile : lockedFiles )
|
||||
{
|
||||
if( msg.IsEmpty() )
|
||||
msg = lockedFile;
|
||||
else
|
||||
msg += "\n" + lockedFile;
|
||||
}
|
||||
|
||||
wxRichMessageDialog dlg( this, wxString::Format( _( "Failed to save %s." ),
|
||||
Schematic().Root().GetFileName() ),
|
||||
_( "Locked File Warning" ),
|
||||
wxOK | wxICON_WARNING | wxCENTER );
|
||||
dlg.SetExtendedMessage( _( "You do not have write permissions to:\n\n" ) + msg );
|
||||
|
||||
dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !overwrittenFiles.IsEmpty() )
|
||||
{
|
||||
for( const wxString& overwrittenFile : overwrittenFiles )
|
||||
|
|
Loading…
Reference in New Issue