Browse Source

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.
Ghostkeeper 8 years ago
parent
commit
675a8c140e
1 changed files with 3 additions and 1 deletions
  1. 3 1
      cura/ExtrudersModel.py

+ 3 - 1
cura/ExtrudersModel.py

@@ -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)