Prevent autosave error from cluttering the screen

Once per session, per editor we can show the error.  After that, assume
that the designer has seen and knows about the issue.

Fixes https://gitlab.com/kicad/code/kicad/issues/21464
This commit is contained in:
Seth Hillbrand 2025-08-15 13:49:32 -07:00
parent fcd2da354d
commit 9f2b04c7e2
4 changed files with 48 additions and 1 deletions

View File

@ -145,6 +145,7 @@ void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType )
m_isNonUserClose = false;
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
m_autoSaveRequired = false;
m_autoSavePermissionError = false;
m_mruPath = PATHS::GetDefaultUserProjectsPath();
m_frameSize = defaultSize( aFrameType, this );
m_displayIndex = -1;

View File

@ -1236,8 +1236,18 @@ bool SCH_EDIT_FRAME::doAutoSave()
if( !tmp.IsOk() )
return false;
if( !IsWritable( tmp ) )
if( !IsWritable( tmp, false ) )
{
if( !m_autoSavePermissionError )
{
DisplayError( this, wxString::Format(
_( "Could not autosave files to read-only folder: '%s'" ),
tmp.GetPath() ) );
m_autoSavePermissionError = true;
}
return false;
}
wxString title = GetTitle(); // Save frame title, that can be modified by the save process
@ -1252,6 +1262,20 @@ bool SCH_EDIT_FRAME::doAutoSave()
// Auto save file name is the normal file name prefixed with GetAutoSavePrefix().
fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() );
if( !IsWritable( fn, false ) )
{
if( !m_autoSavePermissionError )
{
DisplayError( this, wxString::Format(
_( "Could not autosave files to read-only folder: '%s'" ),
fn.GetPath() ) );
m_autoSavePermissionError = true;
}
autoSaveOk = false;
continue;
}
if( saveSchematicFile( screens.GetSheet( i ), fn.GetFullPath() ) )
{
// This was only an auto-save, not a real save. Reset the modified flag.

View File

@ -802,6 +802,7 @@ private:
bool m_autoSavePending;
bool m_autoSaveRequired;
wxTimer* m_autoSaveTimer;
bool m_autoSavePermissionError;
int m_undoRedoCountMax; // undo/Redo command Max depth

View File

@ -1196,12 +1196,33 @@ bool PCB_EDIT_FRAME::DoAutoSave()
// path. If that path isn't writable, give up.
if( !autoSaveFileName.IsDirWritable() )
{
if( !m_autoSavePermissionError )
{
DisplayError( this, wxString::Format(
_( "Could not autosave files to read-only folder: '%s'" ),
autoSaveFileName.GetPath() ) );
m_autoSavePermissionError = true;
}
autoSaveFileName.SetPath( wxFileName::GetTempDir() );
if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
return false;
}
if( !IsWritable( autoSaveFileName, false ) )
{
if( !m_autoSavePermissionError )
{
DisplayError( this, wxString::Format(
_( "Could not autosave files to read-only folder: '%s'" ),
autoSaveFileName.GetPath() ) );
m_autoSavePermissionError = true;
}
return false;
}
wxLogTrace( traceAutoSave,
wxT( "Creating auto save file <" ) + autoSaveFileName.GetFullPath() + wxT( ">" ) );