mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Prevent crashes when a variant could not be found
This should not happen, but we've seen some cases where it would cause a crash, usually when a previous upgrade did something a bit weird (in this specific case; a printer with an empty variant, whereas it should have a variant). Since any change that the user will make will ensure that the variant is no longer empty (eg; any selection of a variant will mean it's no longer empty) and that there is no way back, it should be pretty safe to ignore the situation as it will resolve itself eventually CURA-6992
This commit is contained in:
parent
9aeb9912c8
commit
fb4ce43f0c
2 changed files with 9 additions and 1 deletions
|
@ -39,7 +39,11 @@ class IntentManager(QObject):
|
|||
# an empty list if nothing was found.
|
||||
def intentMetadatas(self, definition_id: str, nozzle_name: str, material_base_file: str) -> List[Dict[str, Any]]:
|
||||
intent_metadatas = [] # type: List[Dict[str, Any]]
|
||||
materials = ContainerTree.getInstance().machines[definition_id].variants[nozzle_name].materials
|
||||
try:
|
||||
materials = ContainerTree.getInstance().machines[definition_id].variants[nozzle_name].materials
|
||||
except KeyError:
|
||||
Logger.log("w", "Unable to find the machine %s or the variant %s", definition_id, nozzle_name)
|
||||
materials = {}
|
||||
if material_base_file not in materials:
|
||||
return intent_metadatas
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue