From e0b926878f732608ee3b471f8141dba975dd62fd Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 27 Oct 2016 15:38:17 +0200 Subject: [PATCH] Remove code that sets incompatible materials to invalid type Instead use the "compatible" metadata entry like we do for nozzles. Setting the type differently caused all code that looks for materials to fail because "incompatible_material" is not "material". Since this is the base file, this meant a lot of materials failed to duplicate properly which caused crashes. Contributes to CURA-2821 --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index baf986067a..d6f16b08e9 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -411,6 +411,8 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): else: Logger.log("d", "Unsupported material setting %s", key) + self.addMetaDataEntry("compatible", global_compatibility) + self._dirty = False machines = data.iterfind("./um:settings/um:machine", self.__namespaces) @@ -447,6 +449,7 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): new_material.setName(self.getName()) new_material.setMetaData(copy.deepcopy(self.getMetaData())) new_material.setDefinition(definition) + new_material.setMetaDataEntry("compatible", machine_compatibility) for key, value in global_setting_values.items(): new_material.setProperty(key, "value", value, definition) @@ -492,7 +495,7 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): new_hotend_material.setMetaData(copy.deepcopy(self.getMetaData())) new_hotend_material.setDefinition(definition) new_hotend_material.addMetaDataEntry("variant", variant_containers[0].id) - new_hotend_material.addMetaDataEntry("compatible", hotend_compatibility) + new_hotend_material.setMetaDataEntry("compatible", hotend_compatibility) for key, value in global_setting_values.items(): new_hotend_material.setProperty(key, "value", value, definition) @@ -506,14 +509,6 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): new_hotend_material._dirty = False UM.Settings.ContainerRegistry.getInstance().addContainer(new_hotend_material) - if not global_compatibility: - # Change the type of this container so it is not shown as an option in menus. - # This uses InstanceContainer.setMetaDataEntry because otherwise all containers that - # share this basefile are also updated. - dirty = self.isDirty() - super().setMetaDataEntry("type", "incompatible_material") - super().setDirty(dirty) # reset dirty flag after setMetaDataEntry - def _addSettingElement(self, builder, instance): try: key = UM.Dictionary.findKey(self.__material_property_setting_map, instance.definition.key)