From eb8b3e01e3b2ba39bbbad377dcd5aa6d0f354d40 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 23 May 2016 18:10:35 +0200 Subject: [PATCH] Properly catch exceptions when serializing containers and check for dirty state --- cura/CuraApplication.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index bfe342d1e4..dc3d777c2f 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -193,7 +193,17 @@ class CuraApplication(QtApplication): ## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently. def _onExit(self): for instance in ContainerRegistry.getInstance().findInstanceContainers(): - data = instance.serialize() + if not instance.isDirty(): + continue + + try: + data = instance.serialize() + except NotImplementedError: + continue + except Exception: + Logger.logException("e", "An exception occurred when serializing container %s", instance.getId()) + continue + file_name = urllib.parse.quote_plus(instance.getId()) + ".inst.cfg" instance_type = instance.getMetaDataEntry("type") path = None @@ -211,7 +221,17 @@ class CuraApplication(QtApplication): f.write(data) for stack in ContainerRegistry.getInstance().findContainerStacks(): - data = stack.serialize() + if not stack.isDirty(): + continue + + try: + data = stack.serialize() + except NotImplementedError: + continue + except Exception: + Logger.logException("e", "An exception occurred when serializing container %s", instance.getId()) + continue + file_name = urllib.parse.quote_plus(stack.getId()) + ".stack.cfg" path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name) with SaveFile(path, "wt", -1, "utf-8") as f: