Fix lookup for upgraded intents

CURA-10406
This commit is contained in:
Jaime van Kessel 2023-03-17 16:19:42 +01:00
parent 884ec911e7
commit 14ec6560e4
No known key found for this signature in database
GPG key ID: C85F7A3AF1BAA7C4
2 changed files with 16 additions and 1 deletions

View file

@ -464,9 +464,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# If the global stack is found, we check if there are conflicts in the extruder stacks # If the global stack is found, we check if there are conflicts in the extruder stacks
for extruder_stack_file in extruder_stack_files: for extruder_stack_file in extruder_stack_files:
serialized = archive.open(extruder_stack_file).read().decode("utf-8") serialized = archive.open(extruder_stack_file).read().decode("utf-8")
not_upgraded_serialize = serialized
serialized = ExtruderStack._updateSerialized(serialized, extruder_stack_file)
parser = ConfigParser(interpolation = None) parser = ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
not_upgraded_parser = ConfigParser(interpolation = None)
not_upgraded_parser.read_string(not_upgraded_serialize)
# The check should be done for the extruder stack that's associated with the existing global stack, # The check should be done for the extruder stack that's associated with the existing global stack,
# and those extruder stacks may have different IDs. # and those extruder stacks may have different IDs.
# So we check according to the positions # So we check according to the positions
@ -496,9 +502,16 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
extruder_info.user_changes_info = instance_container_info_dict[user_changes_id] extruder_info.user_changes_info = instance_container_info_dict[user_changes_id]
self._machine_info.extruder_info_dict[position] = extruder_info self._machine_info.extruder_info_dict[position] = extruder_info
intent_container_id = parser["containers"][str(_ContainerIndexes.Intent)]
intent_id = parser["containers"][str(_ContainerIndexes.Intent)] intent_id = parser["containers"][str(_ContainerIndexes.Intent)]
if intent_id not in ("empty", "empty_intent"): if intent_id not in ("empty", "empty_intent"):
extruder_info.intent_info = instance_container_info_dict[intent_id] if intent_container_id in instance_container_info_dict:
extruder_info.intent_info = instance_container_info_dict[intent_id]
else:
# It can happen that an intent has been renamed. In that case, we should still use the old
# name, since we used that to generate the instance_container_info_dict keys.
extruder_info.intent_info = instance_container_info_dict[not_upgraded_parser["containers"][str(_ContainerIndexes.Intent)]]
if not machine_conflict and containers_found_dict["machine"] and global_stack: if not machine_conflict and containers_found_dict["machine"] and global_stack:
if int(position) >= len(global_stack.extruderList): if int(position) >= len(global_stack.extruderList):

View file

@ -10,6 +10,7 @@ if TYPE_CHECKING:
upgrade = VersionUpgrade52to53.VersionUpgrade52to53() upgrade = VersionUpgrade52to53.VersionUpgrade52to53()
def getMetaData() -> Dict[str, Any]: def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
@ -21,6 +22,7 @@ def getMetaData() -> Dict[str, Any]:
("quality_changes", 4000020): ("quality_changes", 4000021, upgrade.upgradeInstanceContainer), ("quality_changes", 4000020): ("quality_changes", 4000021, upgrade.upgradeInstanceContainer),
("quality", 4000020): ("quality", 4000021, upgrade.upgradeInstanceContainer), ("quality", 4000020): ("quality", 4000021, upgrade.upgradeInstanceContainer),
("user", 4000020): ("user", 4000021, upgrade.upgradeInstanceContainer), ("user", 4000020): ("user", 4000021, upgrade.upgradeInstanceContainer),
("intent", 4000020): ("intent", 4000021, upgrade.upgradeInstanceContainer),
}, },
"sources": { "sources": {
"preferences": { "preferences": {