Fix UM2 upgrade regarding the variant

CURA-4482

UM2 by default doesn't have variants, but if the user enables Olsson
Block, the variant option will become available. This commit fixes the
following cases:

- Make sure that the variant is set on the extruder stack but not the
  global stack
- Extruder stacks don't contain information such as has_variant. Such
  info should be retrieved from the global stack and not just from the
  definition container because they can be overriden by other
  containers.
This commit is contained in:
Lipu Fei 2017-11-17 12:47:28 +01:00
parent e246784df2
commit 2c39612bc8
4 changed files with 14 additions and 4 deletions

View file

@ -37,7 +37,7 @@ class UM2UpgradeSelection(MachineAction):
def setHasVariants(self, has_variants = True):
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack:
variant_container = global_container_stack.variant
variant_container = global_container_stack.extruders["0"].variant
variant_index = global_container_stack.getContainerIndex(variant_container)
if has_variants:
@ -52,7 +52,7 @@ class UM2UpgradeSelection(MachineAction):
search_criteria = { "type": "variant", "definition": "ultimaker2", "id": "*0.4*" }
containers = self._container_registry.findInstanceContainers(**search_criteria)
if containers:
global_container_stack.variant = containers[0]
global_container_stack.extruders["0"].variant = containers[0]
else:
# The metadata entry is stored in an ini, and ini files are parsed as strings only.
# Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False.