From 5f3155118404c1a2dae510e107e825b951dda3bf Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 1 Oct 2019 19:41:02 +0200 Subject: [PATCH] Fix checking for cases where machine creation failed --- .../UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py | 3 +++ .../src/Network/LocalClusterOutputDeviceManager.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index fcf29c018a..c4929fc2d1 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -144,6 +144,9 @@ class CloudOutputDeviceManager: # Create a new machine and activate it. # We do not use use MachineManager.addMachine here because we need to set the cluster ID before activating it. new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + if not new_machine: + Logger.log("e", "Failed creating a new machine") + return new_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) self._connectToOutputDevice(device, new_machine) diff --git a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py index c4c4779a3c..273c64ef4d 100644 --- a/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py @@ -208,6 +208,9 @@ class LocalClusterOutputDeviceManager: # We do not use use MachineManager.addMachine here because we need to set the network key before activating it. # If we do not do this the auto-pairing with the cloud-equivalent device will not work. new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + if not new_machine: + Logger.log("e", "Failed creating a new machine") + return new_machine.setMetaDataEntry(self.META_NETWORK_KEY, device.key) CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) self._connectToOutputDevice(device, new_machine)