mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 03:35:57 +08:00
Give default colour if there is no material
Otherwise it would try to call getMetaDataEntry on None. Contributes to issues CURA-340 and CURA-1278.
This commit is contained in:
parent
4aa495f9ef
commit
675a8c140e
@ -52,9 +52,11 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
|||||||
if not global_container_stack:
|
if not global_container_stack:
|
||||||
return #There is no machine to get the extruders of.
|
return #There is no machine to get the extruders of.
|
||||||
for index, extruder in manager.getMachineExtruders(global_container_stack.getBottom()):
|
for index, extruder in manager.getMachineExtruders(global_container_stack.getBottom()):
|
||||||
|
material = extruder.findContainer(type = "material")
|
||||||
|
colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00"
|
||||||
item = { #Construct an item with only the relevant information.
|
item = { #Construct an item with only the relevant information.
|
||||||
"name": extruder.getName(),
|
"name": extruder.getName(),
|
||||||
"colour": extruder.findContainer(type = "material").getMetaDataEntry("color_code", default = "#FFFF00"),
|
"colour": colour,
|
||||||
"index": index
|
"index": index
|
||||||
}
|
}
|
||||||
self.appendItem(item)
|
self.appendItem(item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user