Only emit changed in unset if there was a change

This commit is contained in:
Florian Bruhin 2018-02-19 21:02:29 +01:00
parent 8fead148e2
commit ab119975e7
2 changed files with 5 additions and 2 deletions

View File

@ -255,7 +255,8 @@ class YamlConfig(QObject):
def unset(self, name, *, pattern=None):
"""Remove the given option name if it's configured."""
self._values[name].remove(pattern)
changed = self._values[name].remove(pattern)
if changed:
self._mark_changed()
def clear(self):

View File

@ -110,7 +110,9 @@ class Values:
def remove(self, pattern=None):
"""Remove the value with the given pattern."""
# FIXME:conf Should this ignore patterns which weren't found?
old_len = len(self._values)
self._values = [v for v in self._values if v.pattern != pattern]
return old_len != len(self._values)
def clear(self):
"""Clear all customization for this value."""