[Spice-commits] 2 commits - gtk/spice-gtk-session.c

Christophe Fergau teuf at kemper.freedesktop.org
Wed Oct 29 04:19:16 PDT 2014


 gtk/spice-gtk-session.c |   41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

New commits:
commit 43e3f6ea012236b1c3759a48b24026bdeff5d7e0
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Oct 28 11:39:09 2014 +0100

    Don't strip \0 from non-text clipboard data
    
    Commit a8f2e2d added recomputation of the length of clipboard data to
    strip the trailing \0 in order to avoid a Windows gtk+ bug. However it's
    doing it too for non-text data, which causes issues when copying images
    as they are very likely to contain \0 within their data. They will thus
    be truncated.
    
    This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1154719

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index ccbd89a..10bd762 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -880,9 +880,8 @@ static void clipboard_received_cb(GtkClipboard *clipboard,
     gpointer conv = NULL;
 
     /* gtk+ internal utf8 newline is always LF, even on windows */
-    if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT &&
-        spice_main_agent_test_capability(s->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
-        {
+    if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
+        if (spice_main_agent_test_capability(s->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
             GError *err = NULL;
 
             conv = spice_unix2dos((gchar*)data, len, &err);
commit 9eda1556cfb1fac4cee9405bc47a8c7d4daaba40
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Oct 28 11:31:15 2014 +0100

    Reindent block of code in clipboard_received_cb
    
    This is in preparation for fixing a regression in image copy&paste. This
    commit only introduces a new (unused) block and reindent the
    corresponding code, it can easily be reviewed with git show -w

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 8dd05f4..ccbd89a 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -882,25 +882,27 @@ static void clipboard_received_cb(GtkClipboard *clipboard,
     /* gtk+ internal utf8 newline is always LF, even on windows */
     if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT &&
         spice_main_agent_test_capability(s->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
-        GError *err = NULL;
+        {
+            GError *err = NULL;
 
-        conv = spice_unix2dos((gchar*)data, len, &err);
-        if (err) {
-            g_warning("Failed to convert text line ending: %s", err->message);
-            g_clear_error(&err);
-            return;
-        }
+            conv = spice_unix2dos((gchar*)data, len, &err);
+            if (err) {
+                g_warning("Failed to convert text line ending: %s", err->message);
+                g_clear_error(&err);
+                return;
+            }
 
-        len = strlen(conv);
-    } else {
-        /* On Windows, with some versions of gtk+, GtkSelectionData::length
-         * will include the final '\0'. When a string with this trailing '\0'
-         * is pasted in some linux applications, it will be pasted as <NIL> or
-         * as an invisible character, which is unwanted. Ensure the length we
-         * send to the agent does not include any trailing '\0'
-         * This is gtk+ bug https://bugzilla.gnome.org/show_bug.cgi?id=734670
-         */
-        len = strlen((const char *)data);
+            len = strlen(conv);
+        } else {
+            /* On Windows, with some versions of gtk+, GtkSelectionData::length
+             * will include the final '\0'. When a string with this trailing '\0'
+             * is pasted in some linux applications, it will be pasted as <NIL> or
+             * as an invisible character, which is unwanted. Ensure the length we
+             * send to the agent does not include any trailing '\0'
+             * This is gtk+ bug https://bugzilla.gnome.org/show_bug.cgi?id=734670
+             */
+            len = strlen((const char *)data);
+        }
     }
 
     spice_main_clipboard_selection_notify(s->main, selection, type,


More information about the Spice-commits mailing list