Prevent crash when machine isn't configured correctly yet

CURA-6600
This commit is contained in:
Jaime van Kessel 2019-08-27 13:50:12 +02:00
parent 3f5563514c
commit 72ea1257d7

View file

@ -116,7 +116,9 @@ class BaseMaterialsModel(ListModel):
# Update the available materials (ContainerNode) for the current active machine and extruder setup.
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
extruder_stack = global_stack.extruders[str(self._extruder_position)]
extruder_stack = global_stack.extruders.get(str(self._extruder_position))
if not extruder_stack:
return
nozzle_name = extruder_stack.variant.getName()
materials = ContainerTree.getInstance().machines[global_stack.definition.getId()].variants[nozzle_name].materials
compatible_material_diameter = str(round(extruder_stack.getCompatibleMaterialDiameter()))