From 186eef0b68d1693219721f51789a1579f4599e0d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 16 May 2019 15:38:44 +0200 Subject: [PATCH] Fix backup causing a crash in specific situations --- cura/Backups/BackupsManager.py | 14 ++++++++++++-- cura/CuraApplication.py | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cura/Backups/BackupsManager.py b/cura/Backups/BackupsManager.py index 91ee578941..ba6fcab8d7 100644 --- a/cura/Backups/BackupsManager.py +++ b/cura/Backups/BackupsManager.py @@ -51,8 +51,18 @@ 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.getAutoSave().setEnabled(False) + auto_save = self._application.getAutoSave() + # The auto save is only not created if the application has not yet started. + if auto_save: + auto_save.setEnabled(False) + else: + Logger.log("e", "Unable to disable the autosave as application init has not been completed") ## Re-enable auto-save after we're done. def _enableAutoSave(self) -> None: - self._application.getAutoSave().setEnabled(True) + auto_save = self._application.getAutoSave() + # The auto save is only not created if the application has not yet started. + if auto_save: + auto_save.setEnabled(True) + else: + Logger.log("e", "Unable to enable the autosave as application init has not been completed") diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 29febf2610..2f845c710f 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -260,7 +260,7 @@ class CuraApplication(QtApplication): self._plugins_loaded = False # Backups - self._auto_save = None + self._auto_save = None # type: Optional[AutoSave] from cura.Settings.CuraContainerRegistry import CuraContainerRegistry self._container_registry_class = CuraContainerRegistry @@ -988,7 +988,7 @@ class CuraApplication(QtApplication): return super().event(event) - def getAutoSave(self): + def getAutoSave(self) -> Optional[AutoSave]: return self._auto_save ## Get print information (duration / material used)