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@xxxxxxxxxx> > --- > > 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@xxxxxxxxxx> > --- > 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@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel