[virt-tools-list] [virt-viewer v1] vnc: only emit 'session-disconnect' if it was connected
Victor Toso
victortoso at redhat.com
Tue Jun 6 09:30:49 UTC 2017
From: Victor Toso <me at victortoso.com>
When user cancels an authentication dialog, virt-viewer-session-vnc.c
will correctly emit "session-cancelled" and after that it will emit
"session-disconnected" which is not correct as the session's
connection was not establish at that moment.
We can track if the session has established a connection with the
signal "vnc-initialized" from VncDisplay.
This patch fixes a wrong authentication dialog that will be displayed
with VNC when it runs on kiosk mode after user tries to cancel or
close the authentication dialog.
The same fix was done for spice in 6480e52f62bc7c87bbdca1aa
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1446161
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
src/virt-viewer-session-vnc.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 26fb405..9e9316e 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -40,6 +40,8 @@ struct _VirtViewerSessionVncPrivate {
GtkWindow *main_window;
/* XXX we should really just have a VncConnection */
VncDisplay *vnc;
+ /* To workaround "vnc-disconnected" when session was not initialized */
+ gboolean initialized;
};
#define VIRT_VIEWER_SESSION_VNC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncPrivate))
@@ -121,7 +123,10 @@ virt_viewer_session_vnc_disconnected(VncDisplay *vnc G_GNUC_UNUSED,
virt_viewer_session_clear_displays(VIRT_VIEWER_SESSION(session));
display = virt_viewer_display_vnc_new(session, session->priv->vnc);
g_debug("Disconnected");
- g_signal_emit_by_name(session, "session-disconnected", NULL);
+ if (session->priv->initialized)
+ g_signal_emit_by_name(session, "session-disconnected", NULL);
+
+ session->priv->initialized = FALSE;
virt_viewer_display_set_enabled(VIRT_VIEWER_DISPLAY(display), FALSE);
virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display),
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY, FALSE);
@@ -131,6 +136,7 @@ static void
virt_viewer_session_vnc_initialized(VncDisplay *vnc G_GNUC_UNUSED,
VirtViewerSessionVnc *session)
{
+ session->priv->initialized = TRUE;
g_signal_emit_by_name(session, "session-initialized");
}
@@ -408,6 +414,7 @@ virt_viewer_session_vnc_new(VirtViewerApp *app, GtkWindow *main_window)
session->priv->vnc = VNC_DISPLAY(vnc_display_new());
g_object_ref_sink(session->priv->vnc);
session->priv->main_window = g_object_ref(main_window);
+ session->priv->initialized = FALSE;
g_signal_connect(session->priv->vnc, "vnc-connected",
G_CALLBACK(virt_viewer_session_vnc_connected), session);
--
2.13.0
More information about the virt-tools-list
mailing list