From 6e2738a25489f5c38d1177915c1f9d51545c4ac3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 8 Sep 2020 12:53:30 +0200 Subject: [PATCH] Don't update extruders that Cura doesn't have This is a bit of defensive coding. If the position is out of bounds for Cura it should now ignore those extruders. This could be due to broken firmware, or maybe someone MITM-ing the connection and changing it, or perhaps because the printer was changed while the sync was ongoing? Whatever the cause, it now puts a warning in the log about it and doesn't crash any more. Fixes Sentry issue CURA-156. --- cura/Settings/MachineManager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 5f540fec5c..a4d6237d80 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1396,6 +1396,9 @@ class MachineManager(QObject): for extruder_configuration in configuration.extruderConfigurations: position = str(extruder_configuration.position) + if int(position) >= len(self._global_container_stack.extruderList): + Logger.warning("Received a configuration for extruder {position}, which is out of bounds for this printer.".format(position=position)) + continue # Remote printer gave more extruders than what Cura had locally, e.g. because the user switched to a single-extruder printer while the sync was being processed. # If the machine doesn't have a hotend or material, disable this extruder if int(position) in extruders_to_disable: