mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Catch ContainerFormatError when deserialising containers
Only the deserialize() functions themselves may pass the ContainerFormatError on, because their callers will have to handle those errors anyway. Contributes to issue CURA-5045.
This commit is contained in:
parent
c9dc429b2b
commit
572721e20d
6 changed files with 48 additions and 23 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import os
|
||||
|
|
@ -11,6 +11,7 @@ from typing import Optional
|
|||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
from UM.Decorators import override
|
||||
from UM.Settings.ContainerFormatError import ContainerFormatError
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.Settings.InstanceContainer import InstanceContainer
|
||||
|
|
@ -25,7 +26,6 @@ from UM.Resources import Resources
|
|||
|
||||
from . import ExtruderStack
|
||||
from . import GlobalStack
|
||||
from .ExtruderManager import ExtruderManager
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch
|
||||
|
|
@ -420,7 +420,6 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
|
||||
Logger.log("d", "Converting ContainerStack {stack} to {type}", stack = container.getId(), type = container_type)
|
||||
|
||||
new_stack = None
|
||||
if container_type == "extruder_train":
|
||||
new_stack = ExtruderStack.ExtruderStack(container.getId())
|
||||
else:
|
||||
|
|
@ -706,7 +705,10 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
instance_container = InstanceContainer(container_id)
|
||||
with open(file_path, "r", encoding = "utf-8") as f:
|
||||
serialized = f.read()
|
||||
instance_container.deserialize(serialized, file_path)
|
||||
try:
|
||||
instance_container.deserialize(serialized, file_path)
|
||||
except ContainerFormatError:
|
||||
continue
|
||||
self.addContainer(instance_container)
|
||||
break
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue