Просмотр исходного кода

Fix data saving before making a backup

CURA-6471
Lipu Fei 5 лет назад
Родитель
Сommit
4876d5af00
3 измененных файлов с 11 добавлено и 7 удалено
  1. 8 0
      cura/AutoSave.py
  2. 2 2
      cura/Backups/BackupsManager.py
  3. 1 5
      cura/CuraApplication.py

+ 8 - 0
cura/AutoSave.py

@@ -19,6 +19,7 @@ class AutoSave:
         self._change_timer.setInterval(self._application.getPreferences().getValue("cura/autosave_delay"))
         self._change_timer.setSingleShot(True)
 
+        self._enabled = True
         self._saving = False
 
     def initialize(self):
@@ -32,6 +33,13 @@ class AutoSave:
         if not self._saving:
             self._change_timer.start()
 
+    def setEnabled(self, enabled: bool) -> None:
+        self._enabled = enabled
+        if self._enabled:
+            self._change_timer.start()
+        else:
+            self._change_timer.stop()
+
     def _onGlobalStackChanged(self):
         if self._global_stack:
             self._global_stack.propertyChanged.disconnect(self._triggerTimer)

+ 2 - 2
cura/Backups/BackupsManager.py

@@ -51,8 +51,8 @@ class BackupsManager:
     ##  Here we try to disable the auto-save plug-in as it might interfere with
     #   restoring a back-up.
     def _disableAutoSave(self) -> None:
-        self._application.setSaveDataEnabled(False)
+        self._application.getAutoSave().setEnabled(False)
 
     ##  Re-enable auto-save after we're done.
     def _enableAutoSave(self) -> None:
-        self._application.setSaveDataEnabled(True)
+        self._application.getAutoSave().setEnabled(True)

+ 1 - 5
cura/CuraApplication.py

@@ -258,7 +258,6 @@ class CuraApplication(QtApplication):
 
         # Backups
         self._auto_save = None
-        self._save_data_enabled = True
 
         from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
         self._container_registry_class = CuraContainerRegistry
@@ -668,13 +667,10 @@ class CuraApplication(QtApplication):
             self._message_box_callback(button, *self._message_box_callback_arguments)
             self._message_box_callback = None
             self._message_box_callback_arguments = []
-            
-    def setSaveDataEnabled(self, enabled: bool) -> None:
-        self._save_data_enabled = enabled
 
     # Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
     def saveSettings(self):
-        if not self.started or not self._save_data_enabled:
+        if not self.started:
             # Do not do saving during application start or when data should not be saved on quit.
             return
         ContainerRegistry.getInstance().saveDirtyContainers()