Handle exception when adhesion extruder could not be found

This should be pretty rare; the crash would only happen due to a race condition

cura-8584
This commit is contained in:
Jaime van Kessel 2021-11-09 10:17:32 +01:00
parent dcf78b4885
commit 73ca50d958

View file

@ -6,6 +6,7 @@ import math
from typing import List, Optional, TYPE_CHECKING, Any, Set, cast, Iterable, Dict from typing import List, Optional, TYPE_CHECKING, Any, Set, cast, Iterable, Dict
from UM.Logger import Logger
from UM.Mesh.MeshData import MeshData from UM.Mesh.MeshData import MeshData
from UM.Mesh.MeshBuilder import MeshBuilder from UM.Mesh.MeshBuilder import MeshBuilder
@ -1078,7 +1079,11 @@ class BuildVolume(SceneNode):
# setting does *not* have a limit_to_extruder setting (which means that we can't ask the global extruder what # setting does *not* have a limit_to_extruder setting (which means that we can't ask the global extruder what
# the value is. # the value is.
adhesion_extruder = self._global_container_stack.getProperty("adhesion_extruder_nr", "value") adhesion_extruder = self._global_container_stack.getProperty("adhesion_extruder_nr", "value")
adhesion_stack = self._global_container_stack.extruderList[int(adhesion_extruder)] try:
adhesion_stack = self._global_container_stack.extruderList[int(adhesion_extruder)]
except IndexError:
Logger.warning(f"Couldn't find extruder with index '{adhesion_extruder}', defaulting to 0 instead.")
adhesion_stack = self._global_container_stack.extruderList[0]
skirt_brim_line_width = adhesion_stack.getProperty("skirt_brim_line_width", "value") skirt_brim_line_width = adhesion_stack.getProperty("skirt_brim_line_width", "value")
initial_layer_line_width_factor = adhesion_stack.getProperty("initial_layer_line_width_factor", "value") initial_layer_line_width_factor = adhesion_stack.getProperty("initial_layer_line_width_factor", "value")