mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Properly catch exceptions when serializing containers and check for dirty state
This commit is contained in:
parent
6116f592b3
commit
eb8b3e01e3
1 changed files with 22 additions and 2 deletions
|
@ -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.
|
## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
|
||||||
def _onExit(self):
|
def _onExit(self):
|
||||||
for instance in ContainerRegistry.getInstance().findInstanceContainers():
|
for instance in ContainerRegistry.getInstance().findInstanceContainers():
|
||||||
|
if not instance.isDirty():
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
data = instance.serialize()
|
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"
|
file_name = urllib.parse.quote_plus(instance.getId()) + ".inst.cfg"
|
||||||
instance_type = instance.getMetaDataEntry("type")
|
instance_type = instance.getMetaDataEntry("type")
|
||||||
path = None
|
path = None
|
||||||
|
@ -211,7 +221,17 @@ class CuraApplication(QtApplication):
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
for stack in ContainerRegistry.getInstance().findContainerStacks():
|
for stack in ContainerRegistry.getInstance().findContainerStacks():
|
||||||
|
if not stack.isDirty():
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
data = stack.serialize()
|
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"
|
file_name = urllib.parse.quote_plus(stack.getId()) + ".stack.cfg"
|
||||||
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
||||||
with SaveFile(path, "wt", -1, "utf-8") as f:
|
with SaveFile(path, "wt", -1, "utf-8") as f:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue