diff options
author | Ghostkeeper <rubend@tutanota.com> | 2019-09-13 15:42:16 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2019-09-13 15:42:27 +0300 |
commit | cc27392ab0c63df4759ca0229ec33e52e6f8b3c3 (patch) | |
tree | 5b7ee45316eb804202d8f6849bb84afee8ce6bc0 /plugins/XmlMaterialProfile/XmlMaterialProfile.py | |
parent | bb0c9c80dc2b8090864ebd4888730c86b77dffe0 (diff) |
Don't use material groups to update metadata
The material groups are not filled any more in the material manager so this fails.
This might make updating metadata of material profiles slightly slower, but when testing this I noticed no difference.
The function becomes a lot simpler though. And it works again.
Contributes to issue CURA-6600.
Diffstat (limited to 'plugins/XmlMaterialProfile/XmlMaterialProfile.py')
-rw-r--r-- | plugins/XmlMaterialProfile/XmlMaterialProfile.py | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 5a1abf0dfb..7dfa6483d2 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -75,36 +75,19 @@ class XmlMaterialProfile(InstanceContainer): if k in self.__material_properties_setting_map: new_setting_values_dict[self.__material_properties_setting_map[k]] = v - # Prevent recursion - if not apply_to_all: - super().setMetaDataEntry(key, value) - for k, v in new_setting_values_dict.items(): - self.setProperty(k, "value", v) - return + if not apply_to_all: # Historical: If you only want to modify THIS container. We only used that to prevent recursion but with the below code that's no longer necessary. + container_query = registry.findContainers(id = self.getId()) + else: + container_query = registry.findContainers(base_file = self.getMetaDataEntry("base_file")) - # Get the MaterialGroup - 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) + for container in container_query: + if key not in container.getMetaData() or container.getMetaData()[key] != value: + container.getMetaData()[key] = value + container.setDirty(True) + container.metaDataChanged.emit(container) for k, v in new_setting_values_dict.items(): self.setProperty(k, "value", v) return - # Update the root material container - root_material_container = material_group.root_material_node.container - if root_material_container is not None: - root_material_container.setMetaDataEntry(key, value, apply_to_all = False) - for k, v in new_setting_values_dict.items(): - root_material_container.setProperty(k, "value", v) - - # Update all containers derived from it - for node in material_group.derived_material_node_list: - container = node.container - if container is not None: - container.setMetaDataEntry(key, value, apply_to_all = False) - for k, v in new_setting_values_dict.items(): - container.setProperty(k, "value", v) ## Overridden from InstanceContainer, similar to setMetaDataEntry. # without this function the setName would only set the name of the specific nozzle / material / machine combination container |