[Spice-devel] [spice-gtk v3] gtk-session: always reply to agent's clipboard request
Victor Toso
victortoso at redhat.com
Fri Feb 24 15:01:00 UTC 2017
Hi,
On Fri, Feb 24, 2017 at 03:39:16PM +0100, Pavel Grunt wrote:
> Hi,
>
> On Fri, 2017-02-24 at 14:28 +0100, Victor Toso wrote:
> > From: Victor Toso <me at victortoso.com>
> >
> > This fixes a regression from 7b0de6217670e0f668aff2949f
> >
> > We need to reply back to the agent all clipboard requests even in
> > case
> > of failure otherwise it will have a pending request. The following
> > error message can be seen afterwards, in the linux agent, when
> > client
> > sends down some clipboard data:
> >
> > > clipboard: selection requests pending on clipboard ownership
> > > change, clearing
> >
> > An easy way to reproduce this is:
> > 1-) In client, copy image from lo-draw (selection or ctrl+c)
> > 2-) In guest, paste it to GEdit (mouse3 our ctrl+v)
> > 3-) Move to the client
> > 4-) Move back to the guest
> > 5-) see error on vdagent logs
> >
> > The reason for failure is that client's clipboard contains different
> > data type (image) then what was requested from guest's editor (text)
> >
> > While at it, include extra debug message as it might be hard to
> > identify why clipboard did not work.
> >
> > Resolves: rhbz#1409854
> > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > ---
> > src/spice-gtk-session.c | 21 +++++++++++++--------
> > 1 file changed, 13 insertions(+), 8 deletions(-)
> >
> > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > index 0426d8f..3be747e 100644
> > --- a/src/spice-gtk-session.c
> > +++ b/src/spice-gtk-session.c
> > @@ -936,35 +936,40 @@ static void
> > clipboard_received_text_cb(GtkClipboard *clipboard,
> > char *conv = NULL;
> > int len = 0;
> > int selection;
> > + const gchar *data = NULL;
> I would use const guchar *
>
> >
> > if (self == NULL)
> > return;
> >
> > + selection = get_selection_from_clipboard(self->priv,
> > clipboard);
> > + g_return_if_fail(selection != -1);
> > +
> > if (text == NULL) {
> > SPICE_DEBUG("Failed to retrieve clipboard text");
> > - return;
> > + goto notify_agent;
> > }
> >
> > g_return_if_fail(SPICE_IS_GTK_SESSION(self));
> >
> > - selection = get_selection_from_clipboard(self->priv,
> > clipboard);
> > - g_return_if_fail(selection != -1);
> > -
> > len = strlen(text);
> > if (!check_clipboard_size_limits(self, len)) {
> > - return;
> > + SPICE_DEBUG("Failed sized limits of clipboard text (%d
> typo
> > bytes)", len);
> > + goto notify_agent;
> > }
> >
> > /* gtk+ internal utf8 newline is always LF, even on windows */
> > conv = fixup_clipboard_text(self, text, &len);
> > if (!check_clipboard_size_limits(self, len)) {
> > - g_free(conv);
> > - return;
> > + SPICE_DEBUG("Failed sized limits of clipboard text (%d
> typo
> > bytes)", len);
> > + goto notify_agent;
> > }
> >
> > + data = (conv != NULL) ? conv : text;
> > +notify_agent:
> > spice_main_clipboard_selection_notify(self->priv->main,
> > selection,
> > VD_AGENT_CLIPBOARD_UTF8_T
> > EXT,
> > - (guchar *)(conv ?: text),
> > len);
> > + (guchar *) data,
> > + (data != NULL) ? len :
> > 0);
> > g_free(conv);
> > }
>
> Besides that Ack,
Hey, many thanks! I'll send the v4 now and wait till next week to push
it. The diff between v3 and v4 is
https://paste.fedoraproject.org/paste/eNBSe0uMYIvWvbzuIwfzQV5M1UNdIGYhyRLivL9gydE=
Cheers,
toso
>
> Pavel
>
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170224/866383f5/attachment.sig>
More information about the Spice-devel
mailing list