Load profile from ContainerRegistry if the stack refers to it

We encountered a case where the version upgrade changed the quality profile to a new one which was specific to the printer rather than a global profile. As the upgraded stack was being read from the project file, it would go look for the new quality profile in the workspace. That ID wouldn't be present in there, and so it would crash and pretend the project file is plain 3MF.
This change makes it fallback to the built-in profiles, for precisely such cases as when a version upgrade changes the stack.

Contributes to issue CURA-8212.
This commit is contained in:
Ghostkeeper 2021-06-03 17:02:05 +02:00
parent 00796b6c99
commit 3dc1dbbbdb
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,4 +1,4 @@
# Copyright (c) 2020 Ultimaker B.V.
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from configparser import ConfigParser
@ -412,7 +412,12 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
quality_container_id = parser["containers"][str(_ContainerIndexes.Quality)]
quality_type = "empty_quality"
if quality_container_id not in ("empty", "empty_quality"):
quality_type = instance_container_info_dict[quality_container_id].parser["metadata"]["quality_type"]
if quality_container_id in instance_container_info_dict:
quality_type = instance_container_info_dict[quality_container_id].parser["metadata"]["quality_type"]
else: # If a version upgrade changed the quality profile in the stack, we'll need to look for it in the built-in profiles instead of the workspace.
quality_matches = ContainerRegistry.getInstance().findContainersMetadata(id = quality_container_id)
if quality_matches: # If there's no profile with this ID, leave it empty_quality.
quality_type = quality_matches[0]["quality_type"]
# Get machine info
serialized = archive.open(global_stack_file).read().decode("utf-8")