From 16eef74c581dc4b8c3ad32de61e964bb51f72f23 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 5 Jan 2017 14:40:19 +0000 Subject: [PATCH] #276: prevent loops leading to deadlocks: * 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 --- src/xpra/clipboard/clipboard_base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xpra/clipboard/clipboard_base.py b/src/xpra/clipboard/clipboard_base.py index 66d6b43f82..8d132bf737 100644 --- a/src/xpra/clipboard/clipboard_base.py +++ b/src/xpra/clipboard/clipboard_base.py @@ -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) @@ -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)