diff options
author | Jack Ha <jackha@gmail.com> | 2017-12-05 11:51:57 +0300 |
---|---|---|
committer | Jack Ha <jackha@gmail.com> | 2017-12-05 11:51:57 +0300 |
commit | ce78bddfbb4e0130df01124253d5e9ff3e013955 (patch) | |
tree | 9d441a967b2d7fda693ce08cc59e157bfb9ba808 /cura/Settings/CuraContainerStack.py | |
parent | 41cde7c7f4520d2840f5c64e6868fba03324e04a (diff) |
Prefer a read-only material in findDefaultMaterial.
Contributes to CURA-4243.
Diffstat (limited to 'cura/Settings/CuraContainerStack.py')
-rwxr-xr-x | cura/Settings/CuraContainerStack.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cura/Settings/CuraContainerStack.py b/cura/Settings/CuraContainerStack.py index bf001c7f08..9e30e3dd66 100755 --- a/cura/Settings/CuraContainerStack.py +++ b/cura/Settings/CuraContainerStack.py @@ -487,11 +487,17 @@ class CuraContainerStack(ContainerStack): search_criteria.pop("name", None) materials = ContainerRegistry.getInstance().findInstanceContainers(**search_criteria) - if materials: - return materials[0] + if not materials: + Logger.log("w", "Could not find a valid material for stack {stack}", stack = self.id) + return None + + for material in materials: + # Prefer a read-only material + if ContainerRegistry.getInstance().isReadOnly(material.getId()): + return material + + return materials[0] - Logger.log("w", "Could not find a valid material for stack {stack}", stack = self.id) - return None ## Find the quality that should be used as "default" quality. # |