Don't crash when switching to printer with fewer extruders

This seems to have happened with an UM2+C.

Fixes Sentry issue CURA-2R5.
This commit is contained in:
Ghostkeeper 2021-09-21 13:40:40 +02:00
parent fe640d42cf
commit 58f4d44694
No known key found for this signature in database
GPG key ID: 68F39EA88EEED5FF

View file

@ -1,4 +1,4 @@
# Copyright (c) 2020 Ultimaker B.V.
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import time
@ -1398,6 +1398,8 @@ class MachineManager(QObject):
# previous one).
self._global_container_stack.setUserChanges(global_user_changes)
for i, user_changes in enumerate(per_extruder_user_changes):
if i >= len(self._global_container_stack.extruderList): # New printer has fewer extruders.
break
self._global_container_stack.extruderList[i].setUserChanges(per_extruder_user_changes[i])
@pyqtSlot(QObject)