Fix serialising materials with submaterials in not loaded container trees

Material profiles need to serialise subprofiles that belong to different printers as well. Some of these materials may not be loaded in the ContainerTree structure. To prevent having to load that as well, we're just not going to use the container tree any more. It turns out that the only reason it was using the container tree was to get the hardware_type metadata from the node in the tree. So just get that from the container itself and we're fine.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-27 15:47:23 +02:00
parent 63ae6ee9ec
commit dabd905853
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -246,10 +246,7 @@ class XmlMaterialProfile(InstanceContainer):
if not variant_name: if not variant_name:
machine_container_map[definition_id] = container machine_container_map[definition_id] = container
if variant_name not in container_tree.machines[definition_id].variants: variant_dict = {"variant_type": container.getMetaDataEntry("hardware_type", str(VariantType.NOZZLE)),
continue
variant_node = container_tree.machines[definition_id].variants[variant_name]
variant_dict = {"variant_node": variant_node,
"material_container": container} "material_container": container}
machine_variant_map[definition_id][variant_name] = variant_dict machine_variant_map[definition_id][variant_name] = variant_dict
@ -284,8 +281,7 @@ class XmlMaterialProfile(InstanceContainer):
# Find all hotend sub-profiles corresponding to this material and machine and add them to this profile. # Find all hotend sub-profiles corresponding to this material and machine and add them to this profile.
buildplate_dict = {} # type: Dict[str, Any] buildplate_dict = {} # type: Dict[str, Any]
for variant_name, variant_dict in machine_variant_map[definition_id].items(): for variant_name, variant_dict in machine_variant_map[definition_id].items():
variant_type = variant_dict["variant_node"].getMetaDataEntry("hardware_type", str(VariantType.NOZZLE)) variant_type = VariantType(variant_dict["variant_type"])
variant_type = VariantType(variant_type)
if variant_type == VariantType.NOZZLE: if variant_type == VariantType.NOZZLE:
# The hotend identifier is not the containers name, but its "name". # The hotend identifier is not the containers name, but its "name".
builder.start("hotend", {"id": variant_name}) builder.start("hotend", {"id": variant_name})