From be6f08deca28137c751b8319cf06bce61c964b86 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 10 Oct 2022 12:04:19 +0100 Subject: [PATCH] Code clarity. (No functional changes.) --- common/eda_base_frame.cpp | 12 ++++++------ common/eda_draw_frame.cpp | 2 +- eeschema/files-io.cpp | 7 ++++++- include/eda_base_frame.h | 2 +- pcbnew/files.cpp | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 6902b75979..a8e40ccaa6 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -122,7 +122,7 @@ void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType ) m_settingsManager = nullptr; m_fileHistory = nullptr; m_supportsAutoSave = false; - m_autoSaveState = false; + m_autoSavePending = false; m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS; m_isClosing = false; m_isNonUserClose = false; @@ -273,20 +273,20 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent ) return true; if( !m_isClosing && m_supportsAutoSave && IsShown() && IsActive() - && m_autoSaveState != isAutoSaveRequired() - && GetAutoSaveInterval() > 0 ) + && m_autoSavePending != isAutoSaveRequired() + && GetAutoSaveInterval() > 0 ) { - if( !m_autoSaveState ) + if( !m_autoSavePending ) { wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) ); m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT ); - m_autoSaveState = true; + m_autoSavePending = true; } else if( m_autoSaveTimer->IsRunning() ) { wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) ); m_autoSaveTimer->Stop(); - m_autoSaveState = false; + m_autoSavePending = false; } } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index ff3809eb6c..fcd2fca627 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -300,7 +300,7 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars else { m_autoSaveTimer->Stop(); - m_autoSaveState = false; + m_autoSavePending = false; } } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 033fe46ff7..a37ebebd95 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -1142,14 +1142,19 @@ bool SCH_EDIT_FRAME::doAutoSave() fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() ); if( saveSchematicFile( screens.GetSheet( i ), fn.GetFullPath() ) ) + { + // This was only an auto-save, not a real save. Reset the modified flag. screens.GetScreen( i )->SetContentModified(); + } else + { autoSaveOk = false; + } } if( autoSaveOk && updateAutoSaveFile() ) { - m_autoSaveState = false; + m_autoSavePending = false; if( !Kiface().IsSingle() && GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave ) diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index dbedc6d739..1884303c0e 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -723,7 +723,7 @@ private: FILE_HISTORY* m_fileHistory; // The frame's recently opened file list bool m_supportsAutoSave; - bool m_autoSaveState; + bool m_autoSavePending; wxTimer* m_autoSaveTimer; int m_undoRedoCountMax; // undo/Redo command Max depth diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 96e36b5cf8..854ce8bd34 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -1246,7 +1246,7 @@ bool PCB_EDIT_FRAME::doAutoSave() GetScreen()->SetContentModified(); GetBoard()->SetFileName( tmpFileName.GetFullPath() ); UpdateTitle(); - m_autoSaveState = false; + m_autoSavePending = false; if( !Kiface().IsSingle() && GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )