[Spice-commits] 3 commits - gtk/channel-main.c gtk/spice-gtk-session.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu Oct 10 08:55:39 PDT 2013


 gtk/channel-main.c      |    5 ++++-
 gtk/spice-gtk-session.c |   11 ++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

New commits:
commit bc892b67c9f900c7ee848b29da07b686897d6aa9
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Oct 10 17:43:01 2013 +0200

    gtk-session: avoid mainloop recursion in clipboard_get
    
    clipboard_get() exits when the clipboard data is received, or when the
    agent connection state change. However, if the agent is already
    disconnected, neither of those 2 conditions can be reached.
    
    Check if the agent is connected before running loop, exit early if not.

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index af491d2..71ed300 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -615,6 +615,7 @@ static void clipboard_get(GtkClipboard *clipboard,
     RunInfo ri = { NULL, };
     SpiceGtkSession *self = user_data;
     SpiceGtkSessionPrivate *s = self->priv;
+    gboolean agent_connected = FALSE;
     gulong clipboard_handler;
     gulong agent_handler;
     int selection;
@@ -642,12 +643,20 @@ static void clipboard_get(GtkClipboard *clipboard,
     spice_main_clipboard_selection_request(s->main, selection,
                                            atom2agent[info].vdagent);
 
+
+    g_object_get(s->main, "agent-connected", &agent_connected, NULL);
+    if (!agent_connected) {
+        SPICE_DEBUG("canceled clipboard_get, before running loop");
+        goto cleanup;
+    }
+
     /* apparently, this is needed to avoid dead-lock, from
        gtk_dialog_run */
     gdk_threads_leave();
     g_main_loop_run(ri.loop);
     gdk_threads_enter();
 
+cleanup:
     g_main_loop_unref(ri.loop);
     ri.loop = NULL;
     g_signal_handler_disconnect(s->main, clipboard_handler);
commit 05175fa45cde61328ef119b917f8e744d07692fc
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Oct 10 17:36:20 2013 +0200

    gtk-session: fix clipboard_agent_connected
    
    Use swapped connection to pass data as first argument to signal handler.

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 476af95..af491d2 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -635,7 +635,7 @@ static void clipboard_get(GtkClipboard *clipboard,
     clipboard_handler = g_signal_connect(s->main, "main-clipboard-selection",
                                          G_CALLBACK(clipboard_got_from_guest),
                                          &ri);
-    agent_handler = g_signal_connect(s->main, "notify::agent-connected",
+    agent_handler = g_signal_connect_swapped(s->main, "notify::agent-connected",
                                      G_CALLBACK(clipboard_agent_connected),
                                      &ri);
 
commit 0704147d40798d27953ebce6c81578a8c42d20c5
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Thu Oct 10 17:31:30 2013 +0200

    main: fix notify of agent disconnection
    
    spice_main_channel_reset_agent() reset connected state, and prevent
    notify of property change.
    
    This is a minor regression introduced in c3adb24425.

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index b342e97..699cff3 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -375,6 +375,9 @@ static void spice_main_channel_reset(SpiceChannel *channel, gboolean migrating)
     agent_free_msg_queue(SPICE_MAIN_CHANNEL(channel));
     c->agent_msg_queue = g_queue_new();
 
+    /* check: if agent_connected can be TRUE, it should call instead
+       set_agent_connected() to notify new state */
+    g_warn_if_fail(c->agent_connected == FALSE);
     spice_main_channel_reset_agent(SPICE_MAIN_CHANNEL(channel));
 
     SPICE_CHANNEL_CLASS(spice_main_channel_parent_class)->channel_reset(channel, migrating);
@@ -1399,8 +1402,8 @@ static void agent_start(SpiceMainChannel *channel)
 /* coroutine context  */
 static void agent_stopped(SpiceMainChannel *channel)
 {
-    spice_main_channel_reset_agent(channel);
     set_agent_connected(channel, FALSE); /* For notify */
+    spice_main_channel_reset_agent(channel);
     emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
 }
 


More information about the Spice-commits mailing list