Log warning when preferred material can't be found

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-22 17:02:09 +02:00
parent 9dca6c0127
commit 9bcf2698d5
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -3,6 +3,7 @@
from typing import Optional, TYPE_CHECKING
from UM.Logger import Logger
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.Interfaces import ContainerInterface
from UM.Signal import Signal
@ -80,7 +81,14 @@ class VariantNode(ContainerNode):
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 next(iter(self.materials.values()))
fallback = next(iter(self.materials.values())) # Should only happen with empty material node.
Logger.log("w", "Could not find preferred material {preferred_material} with diameter {diameter} for variant {variant_id}, falling back to {fallback}.".format(
preferred_material = self.machine.preferred_material,
diameter = approximate_diameter,
variant_id = self.container_id,
fallback = fallback.container_id
))
return fallback
## When a material gets added to the set of profiles, we need to update our
# tree here.