From e9bf05bbab6e2256b5127de9e7b1392096a94691 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 24 Aug 2019 23:37:23 +0200 Subject: [PATCH] Don't unregister subtree if only the child is unset. Because now, grandchildren may have set values. --- src/registry.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/registry.py b/src/registry.py index 793aa0724..ce1b59983 100644 --- a/src/registry.py +++ b/src/registry.py @@ -446,16 +446,23 @@ class Value(Group): 100) convert to an integer in set() and check that the integer is less than 100 in this method. You *must* call this parent method in your own setValue.""" + self._setValue(v, inherited=False) + + def _setValue(self, v, inherited): + """Like setValue, but accepted an extra 'inherited' argument. + inherited=True means the value is inherited from the parent, so if + the parent gets a new value, this group will get the new value as + well.""" self._lastModified = time.time() self.value = v if self._supplyDefault: - for (name, v) in list(self._children.items()): - if not v._wasSet: - self.unregister(name) + for (name, child) in list(self._children.items()): + if not child._wasSet: + child._setValue(v, inherited=True) # We call the callback once everything is clean for callback, args, kwargs in self._callbacks: callback(*args, **kwargs) - self._wasSet = True + self._wasSet = not inherited def context(self, value): """Return a context manager object, which sets this variable to a