[Spice-devel] [spice-gtk 1/2] Reindent block of code in clipboard_received_cb

Christophe Fergeau cfergeau at redhat.com
Tue Oct 28 04:01:21 PDT 2014


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
---
 gtk/spice-gtk-session.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

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,
-- 
2.1.0



More information about the Spice-devel mailing list