diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2013-10-10 17:43:01 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2013-10-10 17:54:15 +0200 |
commit | bc892b67c9f900c7ee848b29da07b686897d6aa9 (patch) | |
tree | 3e6fb0cb8b04f450257c09e6ce053d70b093e357 | |
parent | 05175fa45cde61328ef119b917f8e744d07692fc (diff) | |
download | spice-gtk-bc892b67c9f900c7ee848b29da07b686897d6aa9.tar.gz spice-gtk-bc892b67c9f900c7ee848b29da07b686897d6aa9.tar.xz spice-gtk-bc892b67c9f900c7ee848b29da07b686897d6aa9.zip |
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.
-rw-r--r-- | gtk/spice-gtk-session.c | 9 |
1 files changed, 9 insertions, 0 deletions
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); |