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.
This commit is contained in:
Ghostkeeper 2020-09-08 12:53:30 +02:00
parent 59669f6bad
commit 6e2738a254
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -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: