Copy value before watching it for mutations in config

If we copy it afterwards, we are going to mutate the copied object.
This commit is contained in:
Florian Bruhin 2018-02-19 07:12:27 +01:00
parent ddb914dc65
commit 93972ff3f1

View File

@ -352,12 +352,13 @@ class Config(QObject):
return obj return obj
value = self._values[name].get_for_pattern(pattern) value = self._values[name].get_for_pattern(pattern)
value = self._maybe_copy(value)
# Watch the returned object for changes if it's mutable. # Watch the returned object for changes if it's mutable.
if isinstance(value, self.MUTABLE_TYPES): if isinstance(value, self.MUTABLE_TYPES):
self._mutables[name] = (copy.deepcopy(value), value) self._mutables[name] = (copy.deepcopy(value), value)
return self._maybe_copy(value) return value
def get_str(self, name, *, pattern=None): def get_str(self, name, *, pattern=None):
"""Get the given setting as string. """Get the given setting as string.