Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memleak in sender_seen #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions slip/dbus/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ def _name_owner_changed(self, name, old_owner, new_owner):
if not new_owner and (old_owner, conn) in Object.senders:
Object.senders.remove((old_owner, conn))
Object.connections_senders[conn].remove(old_owner)
if old_owner in Object.connections_smobjs:
Object.connections_smobjs[old_owner].remove()
del Object.connections_smobjs[old_owner]

if len(Object.connections_senders[conn]) == 0:
Object.connections_smobjs[conn].remove()
del Object.connections_senders[conn]
del Object.connections_smobjs[conn]

if not self.persistent and len(Object.senders) == 0 and \
Object.current_source is None:
Expand All @@ -251,10 +252,10 @@ def sender_seen(self, sender):
Object.senders.add((sender, self.connection))
if self.connection not in Object.connections_senders:
Object.connections_senders[self.connection] = set()
Object.connections_smobjs[self.connection] = \
self.connection.add_signal_receiver(
handler_function=self._name_owner_changed,
signal_name='NameOwnerChanged',
dbus_interface='org.freedesktop.DBus',
arg1=sender)
Object.connections_smobjs[sender] = \
self.connection.add_signal_receiver(
handler_function=self._name_owner_changed,
signal_name='NameOwnerChanged',
dbus_interface='org.freedesktop.DBus',
arg1=sender)
Object.connections_senders[self.connection].add(sender)