mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Fix finding existing variant by id
ContainerStack.findContainer cannot find a container by id directly.
This commit is contained in:
parent
78475d68b3
commit
497b6f99a4
1 changed files with 11 additions and 10 deletions
|
@ -32,18 +32,19 @@ class MachineSettingsAction(MachineAction):
|
||||||
# First check if there is a variant previously generated by this machine
|
# First check if there is a variant previously generated by this machine
|
||||||
machine_settings_variant = global_container_stack.findContainer({"type": "variant", "subtype": "machine_settings"})
|
machine_settings_variant = global_container_stack.findContainer({"type": "variant", "subtype": "machine_settings"})
|
||||||
if not machine_settings_variant:
|
if not machine_settings_variant:
|
||||||
# There may be a variant created by the UMOUpgradeSelection machine action
|
variant = global_container_stack.findContainer({"type": "variant"})
|
||||||
machine_settings_variant = global_container_stack.findContainer({"type": "variant", "id": global_container_stack.getName() + "_variant"})
|
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)
|
||||||
|
|
||||||
if not machine_settings_variant:
|
if not machine_settings_variant:
|
||||||
variant = global_container_stack.findContainer({"type": "variant"})
|
# Add a new variant to store the machine settings
|
||||||
if variant and variant.getId() == "empty_variant":
|
machine_settings_variant = self._createMachineSettingsVariant(global_container_stack)
|
||||||
# There is an empty variant that we can use 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
|
|
||||||
machine_settings_variant = self._createMachineSettingsVariant(global_container_stack)
|
|
||||||
|
|
||||||
# Notify the UI in which container to store the machine settings data
|
# Notify the UI in which container to store the machine settings data
|
||||||
container_index = global_container_stack.getContainerIndex(machine_settings_variant)
|
container_index = global_container_stack.getContainerIndex(machine_settings_variant)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue