mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-20 12:49:38 +08:00
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.
This commit is contained in:
parent
78848567e0
commit
021a33d6bd
@ -59,12 +59,17 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
|
|||||||
definition = self._stack.getSettingDefinition(item)
|
definition = self._stack.getSettingDefinition(item)
|
||||||
if definition:
|
if definition:
|
||||||
new_instance = SettingInstance(definition, settings)
|
new_instance = SettingInstance(definition, settings)
|
||||||
|
stack_nr = -1
|
||||||
if definition.global_inherits_stack and self._stack.getProperty("machine_extruder_count", "value") > 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.
|
#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.
|
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.
|
if stack_nr not in ExtruderManager.getInstance().extruderIds and self._stack.getProperty("extruder_nr", "value"): #Property not defined, but we have an extruder number.
|
||||||
extruder_stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0]
|
stack_nr = str(int(round(float(self._stack.getProperty("extruder_nr", "value")))))
|
||||||
new_instance.setProperty("value", extruder_stack.getProperty(item, "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)
|
settings.addInstance(new_instance)
|
||||||
visibility_changed = True
|
visibility_changed = True
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user