[spice-gtk v1 2/4] gtk-session: prefer early check to agent connectivity

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

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

In case the agent is disconnected, we we don't need to create the
struct RunInfo, GMainLoop and add handlers to some signals.

This patch also removes one goto and related cleanup label.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/spice-gtk-session.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 8d31045..1615172 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -725,6 +725,12 @@ static void clipboard_get(GtkClipboard *clipboard,
     g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent));
     g_return_if_fail(s->main != NULL);
 
+    g_object_get(s->main, "agent-connected", &agent_connected, NULL);
+    if (!agent_connected) {
+        SPICE_DEBUG("Request to guest failed as agent is not running");
+        return;
+    }
+
     ri.selection_data = selection_data;
     ri.info = info;
     ri.loop = g_main_loop_new(NULL, FALSE);
@@ -741,13 +747,6 @@ static void clipboard_get(GtkClipboard *clipboard,
     spice_main_channel_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;
-    }
-
     /* This is modeled on the implementation of gtk_dialog_run() even though
      * these thread functions are deprecated and appears to be needed to avoid
      * dead-lock from gtk_dialog_run().
@@ -758,7 +757,6 @@ static void clipboard_get(GtkClipboard *clipboard,
     gdk_threads_enter();
     G_GNUC_END_IGNORE_DEPRECATIONS
 
-cleanup:
     g_clear_pointer(&ri.loop, g_main_loop_unref);
     g_signal_handler_disconnect(s->main, clipboard_handler);
     g_signal_handler_disconnect(s->main, agent_handler);
-- 
2.19.2

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




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