From: Victor Toso <m...@victortoso.com>

To help track race conditions and bad/unexpected behavior in general.

Signed-off-by: Victor Toso <victort...@redhat.com>
---
 src/spice-gtk-session.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index ac2ba0b..bdb1d9d 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -544,7 +544,7 @@ static void clipboard_handler_get_targets_cb(GtkClipboard 
*clipboard,
 {
     SpiceGtkSession *self = free_weak_ref(user_data);
 
-    SPICE_DEBUG("%s:", __FUNCTION__);
+    SPICE_DEBUG("%s natoms=%d from %p", __func__, n_atoms, clipboard);
 
     if (self == NULL)
         return;
@@ -704,9 +704,10 @@ client_clipboard_received_data(SpiceMainChannel *main,
     SpiceGtkSessionPrivate *s = ri->self->priv;
     gchar *conv = NULL;
 
-    g_return_if_fail(selection == ri->selection);
+    SPICE_DEBUG("%s %u bytes (%p) for sel=%u type=%u",
+                __func__, size, data, selection, type);
 
-    SPICE_DEBUG("clipboard got data");
+    g_return_if_fail(selection == ri->selection);
 
     if (atom2agent[ri->info].vdagent == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
         /* on windows, gtk+ would already convert to LF endings, but
@@ -751,12 +752,11 @@ client_clipboard_request_data(GtkClipboard *clipboard,
     gboolean agent_connected = FALSE;
     gulong clipboard_handler;
     gulong agent_handler;
-    int selection;
 
-    SPICE_DEBUG("clipboard get");
-
-    selection = get_selection_from_clipboard(s, clipboard);
+    int selection = get_selection_from_clipboard(s, clipboard);
     g_return_if_fail(selection != -1);
+    SPICE_DEBUG("%s for sel=%d (%p)", __func__, selection, clipboard);
+
     g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent));
     g_return_if_fail(s->main != NULL);
 
@@ -801,7 +801,7 @@ cleanup:
 static void
 clipboard_handler_clear(GtkClipboard *clipboard, gpointer user_data)
 {
-    SPICE_DEBUG("clipboard_clear");
+    SPICE_DEBUG("%s on %p", __func__, clipboard);
     /* We watch for clipboard ownership changes and act on those, so we
        don't need to do anything here */
 }
@@ -846,6 +846,9 @@ guest_clipboard_grab(SpiceMainChannel *main,
         }
     }
 
+    SPICE_DEBUG("%s selection=%u (%p), might request %d/%u types",
+                __func__, selection, cb, num_targets, ntypes);
+
     g_free(s->clip_targets[selection]);
     s->nclip_targets[selection] = num_targets;
     s->clip_targets[selection] = g_memdup(targets, sizeof(GtkTargetEntry) * 
num_targets);
@@ -1014,6 +1017,7 @@ guest_clipboard_request_send_data(GtkClipboard *clipboard,
      */
     g_warn_if_fail(type != VD_AGENT_CLIPBOARD_UTF8_TEXT);
 
+    SPICE_DEBUG("%s %d bytes for selection=%d (%p) type=%u", __func__, len, 
selection, clipboard, type);
     spice_main_channel_clipboard_selection_notify(s->main, selection, type, 
data, len);
 }
 
@@ -1034,6 +1038,8 @@ guest_clipboard_request_data(SpiceMainChannel *main,
 
     cb = get_clipboard_from_selection(s, selection);
     g_return_val_if_fail(cb != NULL, FALSE);
+    SPICE_DEBUG("%s selection=%u (%p) type=%u", __func__, selection, cb, type);
+
     g_return_val_if_fail(s->clipboard_by_guest[selection] == FALSE, FALSE);
     g_return_val_if_fail(s->clip_grabbed[selection], FALSE);
 
@@ -1072,6 +1078,8 @@ guest_clipboard_release(SpiceMainChannel *main,
     SpiceGtkSessionPrivate *s = self->priv;
     GtkClipboard* clipboard = get_clipboard_from_selection(s, selection);
 
+    SPICE_DEBUG("%s selection=%u (%p)", __func__, selection, clipboard);
+
     if (!clipboard)
         return;
 
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to