mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 03:59:04 +08:00
Prevent a KeyError from messing
CURA-5978
This commit is contained in:
parent
a6a364c337
commit
3ad1802ab6
@ -915,9 +915,12 @@ class MachineManager(QObject):
|
||||
|
||||
if settable_per_extruder:
|
||||
limit_to_extruder = int(self._global_container_stack.getProperty(setting_key, "limit_to_extruder"))
|
||||
extruder_position = str(max(0, limit_to_extruder))
|
||||
extruder_stack = self._global_container_stack.extruders[extruder_position]
|
||||
extruder_position = max(0, limit_to_extruder)
|
||||
extruder_stack = self.getExtruder(extruder_position)
|
||||
if extruder_stack:
|
||||
extruder_stack.userChanges.setProperty(setting_key, "value", global_user_container.getProperty(setting_key, "value"))
|
||||
else:
|
||||
Logger.log("e", "Unable to find extruder on position %s", extruder_position)
|
||||
global_user_container.removeInstance(setting_key)
|
||||
|
||||
# Signal that the global stack has changed
|
||||
@ -926,10 +929,9 @@ class MachineManager(QObject):
|
||||
|
||||
@pyqtSlot(int, result = QObject)
|
||||
def getExtruder(self, position: int) -> Optional[ExtruderStack]:
|
||||
extruder = None
|
||||
if self._global_container_stack:
|
||||
extruder = self._global_container_stack.extruders.get(str(position))
|
||||
return extruder
|
||||
return self._global_container_stack.extruders.get(str(position))
|
||||
return None
|
||||
|
||||
def updateDefaultExtruder(self) -> None:
|
||||
if self._global_container_stack is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user