Fix finding existing variant by id

ContainerStack.findContainer cannot find a container by id directly.
This commit is contained in:
fieldOfView 2016-11-08 17:40:27 +01:00
parent 78475d68b3
commit 497b6f99a4

View file

@ -31,18 +31,19 @@ class MachineSettingsAction(MachineAction):
# First check if there is a variant previously generated by this machine
machine_settings_variant = global_container_stack.findContainer({"type": "variant", "subtype": "machine_settings"})
if not machine_settings_variant:
# There may be a variant created by the UMOUpgradeSelection machine action
machine_settings_variant = global_container_stack.findContainer({"type": "variant", "id": global_container_stack.getName() + "_variant"})
if not machine_settings_variant:
variant = global_container_stack.findContainer({"type": "variant"})
if variant and variant.getId() == "empty_variant":
# There is an empty variant that we can use to store the machine settings
if variant:
if variant.getId() == global_container_stack.getName() + "_variant":
# There is a variant created by the UMOUpgradeSelection machine action
machine_settings_variant = variant
if variant.getId() == "empty_variant":
# There is an empty variant that we can replace to store the machine settings
container_index = global_container_stack.getContainerIndex(variant)
machine_settings_variant = self._createMachineSettingsVariant(global_container_stack, container_index)
else:
# Add a second variant before the current variant to store the machine settings
if not machine_settings_variant:
# Add a new variant to store the machine settings
machine_settings_variant = self._createMachineSettingsVariant(global_container_stack)
# Notify the UI in which container to store the machine settings data