From f6089ed627961255554b35fbcb0dc002535d71e9 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 11 Sep 2019 15:43:35 +0200 Subject: [PATCH] Don't use material manager to get list of materials to send The material manager is no longer populated so it wouldn't send any materials any more. This is probably faster anyway since it doesn't need to go back to the container registry for every file. Contributes to issue CURA-6600. --- .../src/Network/SendMaterialJob.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py b/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py index 8de732e2a6..5637f388c1 100644 --- a/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py +++ b/plugins/UM3NetworkPrinting/src/Network/SendMaterialJob.py @@ -68,10 +68,10 @@ class SendMaterialJob(Job): # \param materials_to_send A set with id's of materials that must be sent. def _sendMaterials(self, materials_to_send: Set[str]) -> None: container_registry = CuraApplication.getInstance().getContainerRegistry() - material_manager = CuraApplication.getInstance().getMaterialManager() - material_group_dict = material_manager.getAllMaterialGroups() + all_materials = container_registry.findInstanceContainersMetadata(type = "material") + all_root_materials = {material["base_file"] for material in all_materials if "base_file" in material} # Filters out uniques by making it a set. Don't include files without base file (i.e. empty material). - for root_material_id in material_group_dict: + for root_material_id in all_root_materials: if root_material_id not in materials_to_send: # If the material does not have to be sent we skip it. continue @@ -128,20 +128,18 @@ class SendMaterialJob(Job): @staticmethod def _getLocalMaterials() -> Dict[str, LocalMaterial]: result = {} # type: Dict[str, LocalMaterial] - material_manager = CuraApplication.getInstance().getMaterialManager() - material_group_dict = material_manager.getAllMaterialGroups() + all_materials = CuraApplication.getInstance().getContainerRegistry().findInstanceContainersMetadata(type = "material") + all_root_materials = [material for material in all_materials if material["id"] == material.get("base_file")] # Don't send materials without base_file: The empty material doesn't need to be sent. # Find the latest version of all material containers in the registry. - for root_material_id, material_group in material_group_dict.items(): - material_metadata = ContainerRegistry.getInstance().findContainersMetadata(id = material_group.root_material_node.container_id)[0] - + for material_metadata in all_root_materials: try: # material version must be an int material_metadata["version"] = int(material_metadata["version"]) # Create a new local material local_material = LocalMaterial(**material_metadata) - local_material.id = root_material_id + local_material.id = material_metadata["id"] if local_material.GUID not in result or \ local_material.GUID not in result or \