[virt-tools-list] [PATCH 09/11] virt_viewer_app_quit: Cleanly close the connection before quiting

Hans de Goede hdegoede at redhat.com
Sun Mar 4 19:06:00 UTC 2012


Even though the previous patches in this series ensure that the session
gets properly finalized, we still need to wait for the disconnect signal,
as spice-glib uses co-routines which need some time to cleanly close the
connection / session.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/virt-viewer-app.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 2a66142..49b50d4 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -117,6 +117,7 @@ struct _VirtViewerAppPrivate {
     gboolean started;
     gboolean fullscreen;
     gboolean attach;
+    gboolean quiting;
 
     VirtViewerSession *session;
     gboolean active;
@@ -209,8 +210,14 @@ virt_viewer_app_quit(VirtViewerApp *self)
     g_return_if_fail(VIRT_VIEWER_IS_APP(self));
     VirtViewerAppPrivate *priv = self->priv;
 
-    if (priv->session)
+    if (priv->session) {
         virt_viewer_session_close(VIRT_VIEWER_SESSION(priv->session));
+        if (priv->connected) {
+            priv->quiting = TRUE;
+            return;
+        }
+    }
+
     gtk_main_quit();
 }
 
@@ -1055,6 +1062,9 @@ virt_viewer_app_disconnected(VirtViewerSession *session G_GNUC_UNUSED,
 {
     VirtViewerAppPrivate *priv = self->priv;
 
+    if (priv->quiting)
+        gtk_main_quit();
+
     if (!priv->connected && !priv->cancelled) {
         virt_viewer_app_simple_message_dialog(self,
                                               _("Unable to connect to the graphic server %s"),
-- 
1.7.7.6




More information about the virt-tools-list mailing list