Make the deletion of the definitionChanges safer

Just in case findContainerStacks returns an empty list
This commit is contained in:
Kostas Karmas 2020-06-23 10:56:48 +02:00
parent 61def4ba25
commit d0d7e671ed

View file

@ -738,8 +738,9 @@ class MachineManager(QObject):
containers = CuraContainerRegistry.getInstance().findInstanceContainersMetadata(type = "user", machine = machine_id)
for container in containers:
CuraContainerRegistry.getInstance().removeContainer(container["id"])
machine_stack = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", name = machine_id)[0]
CuraContainerRegistry.getInstance().removeContainer(machine_stack.definitionChanges.getId())
machine_stacks = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", name = machine_id)
if machine_stacks:
CuraContainerRegistry.getInstance().removeContainer(machine_stacks[0].definitionChanges.getId())
CuraContainerRegistry.getInstance().removeContainer(machine_id)
# If the printer that is being removed is a network printer, the hidden printers have to be also removed