Don't crash on editing metadata entries of non-registered materials

Sometimes we need to create a temporary material profile just to save it to file.

Contributes to issue CURA-5787.
This commit is contained in:
Ghostkeeper 2019-02-14 14:03:38 +01:00
parent dbb8514a6a
commit d6f116b156
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -71,7 +71,9 @@ class XmlMaterialProfile(InstanceContainer):
material_manager = CuraApplication.getInstance().getMaterialManager()
root_material_id = self.getMetaDataEntry("base_file") #if basefile is self.getId, this is a basefile.
material_group = material_manager.getMaterialGroup(root_material_id)
if not material_group: #If the profile is not registered in the registry but loose/temporary, it will not have a base file tree.
super().setMetaDataEntry(key, value)
return
# Update the root material container
root_material_container = material_group.root_material_node.getContainer()
if root_material_container is not None: