[PATCH spice-gtk] gtk-session: avoid mainloop recursion in clipboard_get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 agent is connected before running loop, exit early if not.
---
 gtk/spice-gtk-session.c | 9 +++++++++
 1 file changed, 9 insertions(+)

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);
-- 
1.8.3.1

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]