Don't leak invalid properties
This commit is contained in:
parent
92416d1519
commit
26ed1d1504
@ -205,31 +205,35 @@ class Buddy(DBusGObject):
|
|||||||
|
|
||||||
def set_properties(self, properties):
|
def set_properties(self, properties):
|
||||||
changed = False
|
changed = False
|
||||||
|
changed_props = {}
|
||||||
if "nick" in properties.keys():
|
if "nick" in properties.keys():
|
||||||
nick = properties["nick"]
|
nick = properties["nick"]
|
||||||
if nick != self._nick:
|
if nick != self._nick:
|
||||||
self._nick = nick
|
self._nick = nick
|
||||||
|
changed_props["nick"] = nick
|
||||||
changed = True
|
changed = True
|
||||||
if "color" in properties.keys():
|
if "color" in properties.keys():
|
||||||
color = properties["color"]
|
color = properties["color"]
|
||||||
if color != self._color:
|
if color != self._color:
|
||||||
self._color = color
|
self._color = color
|
||||||
|
changed_props["color"] = color
|
||||||
changed = True
|
changed = True
|
||||||
if "current-activity" in properties.keys():
|
if "current-activity" in properties.keys():
|
||||||
curact = properties["current-activity"]
|
curact = properties["current-activity"]
|
||||||
if curact != self._current_activity:
|
if curact != self._current_activity:
|
||||||
self._current_activity = curact
|
self._current_activity = curact
|
||||||
|
changed_props["current-activity"] = curact
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if not changed:
|
if not changed or not len(changed_props.keys()):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Try emitting PropertyChanged before updating validity
|
# Try emitting PropertyChanged before updating validity
|
||||||
# to avoid leaking a PropertyChanged signal before the buddy is
|
# to avoid leaking a PropertyChanged signal before the buddy is
|
||||||
# actually valid the first time after creation
|
# actually valid the first time after creation
|
||||||
if self._valid:
|
if self._valid:
|
||||||
self.PropertyChanged(properties)
|
self.PropertyChanged(changed_props)
|
||||||
self.emit('property-changed', properties)
|
self.emit('property-changed', changed_props)
|
||||||
|
|
||||||
self._update_validity()
|
self._update_validity()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user