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:
Ghostkeeper 2016-06-08 11:00:50 +02:00
parent 4aa495f9ef
commit 675a8c140e
No known key found for this signature in database
GPG key ID: 701948C5954A7385

View file

@ -52,9 +52,11 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
if not global_container_stack:
return #There is no machine to get the extruders of.
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.
"name": extruder.getName(),
"colour": extruder.findContainer(type = "material").getMetaDataEntry("color_code", default = "#FFFF00"),
"colour": colour,
"index": index
}
self.appendItem(item)