We now check if a setting can also be removed to get the same state

THis should prevent the reset buttons from showing up when there is nothing going on.

CURA-1758
This commit is contained in:
Jaime van Kessel 2016-07-22 15:31:37 +02:00
parent fa61a9e3f0
commit be252fb84f

View file

@ -234,6 +234,26 @@ class MachineManager(QObject):
for container in extruder_stack.getContainers(): for container in extruder_stack.getContainers():
if container.__class__ == UM.Settings.InstanceContainer and container.getInstance(key) != None: if container.__class__ == UM.Settings.InstanceContainer and container.getInstance(key) != None:
if container.getProperty(key, "value") != new_value: if container.getProperty(key, "value") != new_value:
# It could be that the setting needs to be removed instead of updated.
temp = extruder_stack
containers = extruder_stack.getContainers()
# Ensure we have the entire 'chain'
while temp.getNextStack():
temp = temp.getNextStack()
containers.extend(temp.getContainers())
instance_needs_removal = False
if len(containers) > 1:
for index in range(1, len(containers)):
deeper_container = containers[index]
if deeper_container.getProperty(key, "value") == new_value:
# Removal will result in correct value, so do that.
# We do this to prevent the reset from showing up unneeded.
instance_needs_removal = True
break
if instance_needs_removal:
extruder_stack.getTop().removeInstance(key)
else:
extruder_stack.getTop().setProperty(key, "value", new_value) extruder_stack.getTop().setProperty(key, "value", new_value)
else: else:
# Check if we really need to remove something. # Check if we really need to remove something.