Added deepcopy function to settingOverrideDecorator

CURA-1636
This commit is contained in:
Jaime van Kessel 2016-06-07 13:33:19 +02:00
parent 51ea6779df
commit 4695862b49

View File

@ -7,7 +7,7 @@ from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Application import Application from UM.Application import Application
import copy
## A decorator that adds a container stack to a Node. This stack should be queried for all settings regarding ## A decorator that adds a container stack to a Node. This stack should be queried for all settings regarding
# the linked node. The Stack in question will refer to the global stack (so that settings that are not defined by # the linked node. The Stack in question will refer to the global stack (so that settings that are not defined by
# this stack still resolve. # this stack still resolve.
@ -25,6 +25,15 @@ class SettingOverrideDecorator(SceneNodeDecorator):
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
self._onGlobalContainerStackChanged() self._onGlobalContainerStackChanged()
def __deepcopy__(self, memo):
## Create a fresh decorator object
deep_copy = SettingOverrideDecorator()
## Copy the stack
deep_copy._stack = copy.deepcopy(self._stack, memo)
## Ensure that the id is unique.
deep_copy._stack._id = id(deep_copy)
return deep_copy
def _onSettingChanged(self, instance, property): def _onSettingChanged(self, instance, property):
if property == "value": # Only reslice if the value has changed. if property == "value": # Only reslice if the value has changed.
Application.getInstance().getBackend().forceSlice() Application.getInstance().getBackend().forceSlice()