From 021a33d6bd5114d3ff7edb8fa0a85c91ba55d08d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 5 Aug 2016 17:30:11 +0200 Subject: [PATCH] Always set value of added setting instance The value property was sometimes not set. In the default case, this just added an empty setting instance (for a particular key), which appeared to do nothing until you've changed it. This appears correct because if it's not changed then it should be the same as the extruder's value, but if you then change the extruder's value it doesn't update its visible value but still has no value in the setting instance, so the value still falls back to the extruder and the setting ends up different from what is being displayed. Contributes to issue CURA-1988. --- .../PerObjectSettingVisibilityHandler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py index cf86a9b48e..e7295c3f97 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py @@ -59,12 +59,17 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand definition = self._stack.getSettingDefinition(item) if definition: new_instance = SettingInstance(definition, settings) + stack_nr = -1 if definition.global_inherits_stack and self._stack.getProperty("machine_extruder_count", "value") > 1: #Obtain the value from the correct container stack. Only once, upon adding the setting. stack_nr = str(int(round(float(self._stack.getProperty(item, "global_inherits_stack"))))) #Stack to get the setting from. Round it and remove the fractional part. - if stack_nr in ExtruderManager.getInstance().extruderIds: #Only if it defines an extruder stack. - extruder_stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0] - new_instance.setProperty("value", extruder_stack.getProperty(item, "value")) + if stack_nr not in ExtruderManager.getInstance().extruderIds and self._stack.getProperty("extruder_nr", "value"): #Property not defined, but we have an extruder number. + stack_nr = str(int(round(float(self._stack.getProperty("extruder_nr", "value"))))) + if stack_nr in ExtruderManager.getInstance().extruderIds: #We have either a global_inherits_stack or an extruder_nr. + stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0] + else: + stack = UM.Application.getInstance().getGlobalContainerStack() + new_instance.setProperty("value", stack.getProperty(item, "value")) settings.addInstance(new_instance) visibility_changed = True else: