Fix crashing when material could not be found

See CURA-3M in sentry. It most commonly happens with the anycubic,
since it had some weird stuff with it suddenly supporting materials.

This change will make it so that no crash happens. Old profiles will still have
an empty material. This isn't really an issue, since the interface will mark this
as an error (prompting users to switch).
This commit is contained in:
Jaime van Kessel 2020-02-17 10:57:24 +01:00
parent b9ff66af00
commit 769fc8fd37
No known key found for this signature in database
GPG Key ID: 3710727397403C91

View File

@ -114,7 +114,10 @@ class IntentModel(ListModel):
Logger.log("w", "Could not find the variant %s", active_variant_name)
continue
active_variant_node = machine_node.variants[active_variant_name]
active_material_node = active_variant_node.materials[extruder.material.getMetaDataEntry("base_file")]
active_material_node = active_variant_node.materials.get(extruder.material.getMetaDataEntry("base_file"))
if active_material_node is None:
Logger.log("w", "Could not find the material %s", extruder.material.getMetaDataEntry("base_file"))
continue
nodes.add(active_material_node)
return nodes