[Spice-devel] [spice-gtk v1] gtk-session: reply agent's clipboard request on failure

Christophe de Dinechin cdupontd at redhat.com
Fri Feb 24 11:13:21 UTC 2017


> On 22 Feb 2017, at 13:29, Victor Toso <victortoso at redhat.com> wrote:
> 
> From: Victor Toso <me at victortoso.com>
> 
> 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 in afterwards, 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)

The patch looks good to me, but one thing I don’t understand is why you modify a function called “clipboard_received_text_cb” when the description of how to reproduce the bug is when you send an image. Is that callback used even for non-text data? If so, could we also rename it?


> 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

Is this the only place where we see the error? Would it be possible to have a non-intrusive notification that the paste operation did not work and why?

> 
> 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.

If it’s hard for you, imagine what it is for Joe MyGrandDadTheLinuxUser ;-)

> 
> Resolves: rhbz#1409854
> Signed-off-by: Victor Toso <victortoso at redhat.com>
> ---
> src/spice-gtk-session.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index 0426d8f..315bc26 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -940,28 +940,33 @@ static void clipboard_received_text_cb(GtkClipboard *clipboard,
>    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 bytes)", len);
> +        len = 0;
> +        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 bytes)", len);
> +        g_clear_pointer(&conv, g_free);
> +        len = 0;
> +        goto notify_agent;
>    }
> 
> +notify_agent:
>    spice_main_clipboard_selection_notify(self->priv->main, selection,
>                                          VD_AGENT_CLIPBOARD_UTF8_TEXT,
>                                          (guchar *)(conv ?: text), len);
> -- 
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



More information about the Spice-devel mailing list