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.
This commit is contained in:
Ghostkeeper 2019-09-11 15:43:35 +02:00
parent f8d72b2ea7
commit f6089ed627
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -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 \