Skip to content

Commit

Permalink
when we stop managing a window, we want to disconnect the handlers au…
Browse files Browse the repository at this point in the history
…tomatically (code was leaking them)

git-svn-id: https://xpra.org/svn/Xpra/trunk@3070 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 15, 2013
1 parent 6b196af commit 5dc303f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
25 changes: 18 additions & 7 deletions src/wimpiggy/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,23 @@ def __init__(self, client_window):
super(BaseWindowModel, self).__init__()
self.client_window = client_window
self._managed = False
self._managed_handlers = []
self._setup_done = False
self._geometry = None
self._damage_forward_handle = None
self._internal_set_property("client-window", client_window)
self._composite = CompositeHelper(self.client_window, False)

def managed_connect(self, detailed_signal, handler, *args):
""" connects a signal handler and makes sure we will clean it up on unmanage() """
handler_id = self.connect(detailed_signal, handler, *args)
self._managed_handlers.append(handler_id)
return handler_id

def managed_disconnect(self):
for handler_id in self._managed_handlers:
self.disconnect(handler_id)

def call_setup(self):
log("call_setup() adding event receiver")
try:
Expand Down Expand Up @@ -310,7 +321,8 @@ def is_managed(self):
return self._managed

def _forward_contents_changed(self, obj, event):
self.emit("client-contents-changed", event)
if self._managed:
self.emit("client-contents-changed", event)

def do_get_property_client_contents(self, name):
return self._composite.get_property("contents")
Expand Down Expand Up @@ -345,6 +357,7 @@ def do_unmanaged(self, wm_exiting):
self._managed = False
log("do_unmanaged(%s) damage_forward_handle=%s, composite=%s", wm_exiting, self._damage_forward_handle, self._composite)
remove_event_receiver(self.client_window, self)
gobject.idle_add(self.managed_disconnect)
if self._composite:
if self._damage_forward_handle:
self._composite.disconnect(self._damage_forward_handle)
Expand Down Expand Up @@ -1231,12 +1244,10 @@ def __init__(self, model):

self._image_window = None
self.model = model
self._redraw_handle = self.model.connect("client-contents-changed",
self._client_contents_changed)
self._election_handle = self.model.connect("ownership-election",
self._vote_for_pedro)
self._unmanaged_handle = self.model.connect("unmanaged",
self._unmanaged)
mc = self.model.managed_connect
self._redraw_handle = mc("client-contents-changed", self._client_contents_changed)
self._election_handle = mc("ownership-election", self._vote_for_pedro)
self._unmanaged_handle = mc("unmanaged", self._unmanaged)

# Standard GTK double-buffering is useless for us, because it's on our
# "official" window, and we don't draw to that.
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ def do_wimpiggy_child_map_event(self, event):

def _add_new_window_common(self, window):
wid = X11ServerBase._add_new_window_common(self, window)
window.connect("client-contents-changed", self._contents_changed)
window.connect("unmanaged", self._lost_window)
window.managed_connect("client-contents-changed", self._contents_changed)
window.managed_connect("unmanaged", self._lost_window)
return wid

_window_export_properties = ("title", "size-hints")
Expand Down

0 comments on commit 5dc303f

Please sign in to comment.