← Back to team overview

kicad-developers team mailing list archive

[BUG] Autosave read-only project

 

Sequence for reproducing (under linux):
1) lauch kicad;
2) open one of demo projects (for example - interf_u);
* by default the demo projects locates in /usr/share/kicad/demos and for
regular user it is available for read only;
3) make some change;
* by default the autosave interval is set to 10 minutes, so...
4) waiting 10 minutes;
* mesagebox shows the mesage "You do not have permissions for writing to
path...";
5) press OK;
* timer starts new loop for next 10 minutes;
6) in settings dialog set autosave interval to 0 (for disabling autosaving);
7) waiting rest of 10 minutes;
8) messagebox shows again - close it;
9) messagebox shows immediately again and again;

It happens, because timer's event handler do not checks autosaveinterval
for zero value.

Propose to resolve this by attached patch.
It allows apply new value of the autosave interval immediately.
diff --git a/common/basicframe.cpp b/common/basicframe.cpp
index 53aea6a..45ad2f4 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 0cc9c5b..1292150 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; }
 

Follow ups