CURA-4606 CURA-5003 fix saving material metadata when switching material; fix crashing on fallback material on materials without fallback

This commit is contained in:
Jack Ha 2018-02-22 15:52:02 +01:00
parent b29d091b1d
commit c7499d6e17
2 changed files with 3 additions and 1 deletions

View file

@ -314,7 +314,8 @@ class MaterialManager(QObject):
def getFallbackMaterialId(self, material_type: str) -> str: def getFallbackMaterialId(self, material_type: str) -> str:
# For safety # For safety
if material_type not in self._fallback_materials_map: if material_type not in self._fallback_materials_map:
raise RuntimeError("Material type [%s] is not in the fallback materials table." % material_type) Logger.log("w", "The material type [%s] does not have a fallback material" % material_type)
return None
fallback_material = self._fallback_materials_map[material_type] fallback_material = self._fallback_materials_map[material_type]
if fallback_material: if fallback_material:
return self.getRootMaterialIDWithoutDiameter(fallback_material["id"]) return self.getRootMaterialIDWithoutDiameter(fallback_material["id"])

View file

@ -350,6 +350,7 @@ Item
onCurrentIndexChanged: onCurrentIndexChanged:
{ {
forceActiveFocus(); // causes the changed fields to be saved
var model = materialsModel.getItem(currentIndex); var model = materialsModel.getItem(currentIndex);
materialDetailsView.containerId = model.container_id; materialDetailsView.containerId = model.container_id;
materialDetailsView.currentMaterialNode = model.container_node; materialDetailsView.currentMaterialNode = model.container_node;