Skip to content

Commit

Permalink
#276: prevent loops leading to deadlocks:
Browse files Browse the repository at this point in the history
* send clipboard token via idle_add - giving enough time for the main loop to run
* "block owner change" when we claim the clipboard

git-svn-id: https://xpra.org/svn/Xpra/trunk@14704 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 5, 2017
1 parent 68d7069 commit 16eef74
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/xpra/clipboard/clipboard_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ def _clipboard_got_contents(self, request_id, dtype, dformat, data):
loop.done({"type": dtype, "format": dformat, "data": data})

def _send_clipboard_token_handler(self, proxy):
#send via idle_add so the main loop can run
#(prevents tight clipboard loops from completely hogging the main loop)
gobject.idle_add(self.do_send_clipboard_token_handler, proxy)

def do_send_clipboard_token_handler(self, proxy):
selection = proxy._selection
log("send clipboard token: %s", selection)
rsel = self.local_to_remote(selection)
Expand Down Expand Up @@ -676,10 +681,12 @@ def got_token(self, targets, target_data, claim):
#not that they want to own the clipboard selection
return
self._have_token = True
if self._can_receive:
if self._can_receive and not self._block_owner_change:
#if we don't claim the selection (can-receive=False),
#we will have to send the token back on owner-change!
self._block_owner_change = True
self.claim()
glib.idle_add(self.remove_block)

def remove_block(self, *args):
log("remove_block: %s", self._selection)
Expand Down

0 comments on commit 16eef74

Please sign in to comment.