From cfc2cc36929daba962cac42a2bf8ff803b4990ba Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 8 Apr 2020 17:14:58 +0200 Subject: [PATCH] Fix crash when printer definition could not be found --- cura/Settings/MachineManager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index aa7c15e28b..36e6c2631f 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1254,7 +1254,11 @@ class MachineManager(QObject): return Logger.log("i", "Attempting to switch the printer type to [%s]", machine_name) # Get the definition id corresponding to this machine name - machine_definition_id = CuraContainerRegistry.getInstance().findDefinitionContainers(name = machine_name)[0].getId() + definitions = CuraContainerRegistry.getInstance().findDefinitionContainers(name=machine_name) + if not definitions: + Logger.log("e", "Unable to switch printer type since it could not be found!") + return + machine_definition_id = definitions[0].getId() # Try to find a machine with the same network key metadata_filter = {"group_id": self._global_container_stack.getMetaDataEntry("group_id")} new_machine = self.getMachine(machine_definition_id, metadata_filter = metadata_filter)