[Spice-devel] [PATCH vdagent-linux] clipboard: cancel request for targets on grab from client

Victor Toso victortoso at redhat.com
Tue Feb 19 15:44:58 UTC 2019


Hi,

On Sun, Feb 17, 2019 at 09:21:11PM +0100, Jakub Janků wrote:
> If gtk_clipboard_set_with_data() is invoked between
> gtk_clipboard_request_targets() and the
> GtkClipboardTargetsReceivedFunc callback,
> the targets we eventually receive are no longer valid.
> 
> To solve this, cancel the request in vdagent_clipboard_grab().
> 
> Otherwise we end up in a situation when vdagent holds
> clipboard grab in the guest but cannot provide data to the
> apps that request it - this can be observed in the log:
> 
>     CRITICAL **: 20:48:55.782: clipboard_get_cb: assertion 'c->selections[sel_id].owner == OWNER_CLIENT' failed
> 
> Signed-off-by: Jakub Janků <jjanku at redhat.com>
> ---
> 
> The same bug is present in spice-gtk as well as
> in the X11 implementation of clipboard in vdagent.

We will need the fix there as well, considering that we have some
systems that will not get the gtk backend as default.

> I'm planing on sending a fix for spice-gtk later
> (possibly with other patches).

jjanku++

> I decided not to fix the X11 clipboard in vdagent as I'm hoping
> it could be removed with the next release.  If you think it
> should get fixed  too, let me know.

Please do fix X11 too, if I'm not asking too much. Preferably in
a different patch...

    Acked-by: Victor Toso <victortoso at redhat.com>

> ---
>  src/vdagent/clipboard.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/vdagent/clipboard.c b/src/vdagent/clipboard.c
> index 6b01a7b..a8d2e91 100644
> --- a/src/vdagent/clipboard.c
> +++ b/src/vdagent/clipboard.c
> @@ -304,6 +304,7 @@ void vdagent_clipboard_grab(VDAgentClipboards *c, guint sel_id,
>      vdagent_x11_clipboard_grab(c->x11, sel_id, types, n_types);
>  #else
>      GtkTargetEntry targets[G_N_ELEMENTS(atom2agent)];
> +    Selection *sel;
>      guint n_targets, i, t;
>  
>      g_return_if_fail(sel_id < SELECTION_COUNT);
> @@ -322,7 +323,13 @@ void vdagent_clipboard_grab(VDAgentClipboards *c, guint sel_id,
>          return;
>      }
>  
> -    if (gtk_clipboard_set_with_data(c->selections[sel_id].clipboard,
> +    sel = &c->selections[sel_id];
> +
> +    if (sel->last_targets_req) {
> +        g_clear_pointer(&sel->last_targets_req, request_ref_cancel);
> +    }
> +
> +    if (gtk_clipboard_set_with_data(sel->clipboard,
>                                      targets, n_targets,
>                                      clipboard_get_cb, clipboard_clear_cb, c))
>          clipboard_new_owner(c, sel_id, OWNER_CLIENT);
> -- 
> 2.20.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190219/04609722/attachment.sig>


More information about the Spice-devel mailing list