From 334c50477ab942180875c560be25b5f60b8dc061 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Nov 2016 11:07:33 +0100 Subject: [PATCH] Auto save: fix case of auto save interval is set to 0 (disabling auto save feature) This fix allows also the new value of the auto save interval immediately taken in account. --- common/basicframe.cpp | 19 +++++++++++++++++++ include/wxstruct.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 53aea6a176..45ad2f4d87 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -200,6 +200,25 @@ bool EDA_BASE_FRAME::Enable( bool enable ) } +void EDA_BASE_FRAME::SetAutoSaveInterval( int aInterval ) +{ + m_autoSaveInterval = aInterval; + + if( m_autoSaveTimer->IsRunning() ) + { + if( m_autoSaveInterval > 0 ) + { + m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT ); + } + else + { + m_autoSaveTimer->Stop(); + m_autoSaveState = false; + } + } +} + + void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent ) { if( !doAutoSave() ) diff --git a/include/wxstruct.h b/include/wxstruct.h index 0cc9c5b550..1292150b4f 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -209,7 +209,7 @@ public: bool Enable( bool enable ) override; - void SetAutoSaveInterval( int aInterval ) { m_autoSaveInterval = aInterval; } + void SetAutoSaveInterval( int aInterval ); int GetAutoSaveInterval() const { return m_autoSaveInterval; }