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

@ -223,8 +223,8 @@ class XmlMaterialProfile(InstanceContainer):
for instance in self.findInstances():
self._addSettingElement(builder, instance)
machine_container_map = {} # type: Dict[str, InstanceContainer]
machine_variant_map = {} # type: Dict[str, Dict[str, Any]]
machine_container_map = {} # type: Dict[str, InstanceContainer]
machine_variant_map = {} # type: Dict[str, Dict[str, Any]]
container_tree = ContainerTree.getInstance()
@ -246,10 +246,7 @@ class XmlMaterialProfile(InstanceContainer):
if not variant_name:
machine_container_map[definition_id] = container
if variant_name not in container_tree.machines[definition_id].variants:
continue
variant_node = container_tree.machines[definition_id].variants[variant_name]
variant_dict = {"variant_node": variant_node,
variant_dict = {"variant_type": container.getMetaDataEntry("hardware_type", str(VariantType.NOZZLE)),
"material_container": container}
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.
buildplate_dict = {} # type: Dict[str, Any]
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_type)
variant_type = VariantType(variant_dict["variant_type"])
if variant_type == VariantType.NOZZLE:
# The hotend identifier is not the containers name, but its "name".
builder.start("hotend", {"id": variant_name})