diff --git a/cura/AutoSave.py b/cura/AutoSave.py index 1639868d6a..605a1e7beb 100644 --- a/cura/AutoSave.py +++ b/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) diff --git a/cura/Backups/BackupsManager.py b/cura/Backups/BackupsManager.py index a0d3881209..91ee578941 100644 --- a/cura/Backups/BackupsManager.py +++ b/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) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 67ff984e03..9dd1168135 100755 --- a/cura/CuraApplication.py +++ b/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()