mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 00:05:59 +08:00
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.
This commit is contained in:
parent
d06ce211ff
commit
9dca6c0127
@ -76,11 +76,11 @@ class VariantNode(ContainerNode):
|
|||||||
# material.
|
# material.
|
||||||
# \return The node for the preferred material, or None if there is no
|
# \return The node for the preferred material, or None if there is no
|
||||||
# match.
|
# match.
|
||||||
def preferredMaterial(self, approximate_diameter) -> Optional[MaterialNode]:
|
def preferredMaterial(self, approximate_diameter) -> MaterialNode:
|
||||||
for base_material, material_node in self.materials.items():
|
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")):
|
if self.machine.preferred_material in base_material and approximate_diameter == int(material_node.getMetaDataEntry("approximate_diameter")):
|
||||||
return material_node
|
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
|
## When a material gets added to the set of profiles, we need to update our
|
||||||
# tree here.
|
# tree here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user