[virt-tools-list] [virt-viewer v2] vnc: do not show error on cancel/close of auth dialog

Victor Toso victortoso at redhat.com
Tue Jun 6 12:12:35 UTC 2017


From: Victor Toso <me at victortoso.com>

Mainly a kiosk mode, similar to the spice fix in 6480e52f62b.

This patch saves the cancel/close state of auth dialog from
virt_viewer_auth_collect_credentials() in order to avoid an error
dialog to pop up to user in kiosk mode.

This happens due the fact that we call virt_viewer_app_disconnected()
twice:
- One with "session-cancelled" which is correct and well handled;
- The other with "session-disconnected" which is misleading as there
  was no connection at this time. This will trigger the error dialog
  with "Unable to connect to the graphic server %s".

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/virt-viewer-session-vnc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 26fb405..beb5130 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -40,6 +40,7 @@ struct _VirtViewerSessionVncPrivate {
     GtkWindow *main_window;
     /* XXX we should really just have a VncConnection */
     VncDisplay *vnc;
+    gboolean auth_dialog_canceled;
 };
 
 #define VIRT_VIEWER_SESSION_VNC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncPrivate))
@@ -104,6 +105,8 @@ virt_viewer_session_vnc_connected(VncDisplay *vnc G_GNUC_UNUSED,
     GtkWidget *display = virt_viewer_display_vnc_new(session, session->priv->vnc);
     VirtViewerApp *app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(session));
 
+    session->priv->auth_dialog_canceled = FALSE;
+
     virt_viewer_window_set_display(virt_viewer_app_get_main_window(app),
                                    VIRT_VIEWER_DISPLAY(display));
 
@@ -117,6 +120,8 @@ virt_viewer_session_vnc_disconnected(VncDisplay *vnc G_GNUC_UNUSED,
                                      VirtViewerSessionVnc *session)
 {
     GtkWidget *display;
+    if (session->priv->auth_dialog_canceled)
+        return;
 
     virt_viewer_session_clear_displays(VIRT_VIEWER_SESSION(session));
     display = virt_viewer_display_vnc_new(session, session->priv->vnc);
@@ -314,6 +319,7 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED,
 
         if (!ret) {
             vnc_display_close(self->priv->vnc);
+            self->priv->auth_dialog_canceled = TRUE;
             g_signal_emit_by_name(self, "session-cancelled");
             goto cleanup;
         }
-- 
2.13.0




More information about the virt-tools-list mailing list