From 9dca6c0127f028e8fba322f5b831c4763b038655 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 22 Aug 2019 16:52:38 +0200 Subject: [PATCH] Return empty node if preferred node couldn't be found Or any node, really. There must now always be a subnode. Contributes to issue CURA-6600. --- cura/Machines/VariantNode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Machines/VariantNode.py b/cura/Machines/VariantNode.py index c1b294963e..836c1336a6 100644 --- a/cura/Machines/VariantNode.py +++ b/cura/Machines/VariantNode.py @@ -76,11 +76,11 @@ class VariantNode(ContainerNode): # material. # \return The node for the preferred material, or None if there is no # match. - def preferredMaterial(self, approximate_diameter) -> Optional[MaterialNode]: + def preferredMaterial(self, approximate_diameter) -> MaterialNode: for base_material, material_node in self.materials.items(): if self.machine.preferred_material in base_material and approximate_diameter == int(material_node.getMetaDataEntry("approximate_diameter")): return material_node - return None + return next(iter(self.materials.values())) ## When a material gets added to the set of profiles, we need to update our # tree here.