[virt-tools-list] [virt-viewer] Silence g_warning() on connection failures

Christophe Fergeau cfergeau at redhat.com
Thu Mar 21 10:13:48 UTC 2013


When starting remote-viewer with spice://example.com:5900 (ie
a non-existing VM), the warning below appears in the console:

(remote-viewer:21735): remote-viewer-CRITICAL **:
virt_viewer_display_get_monitor: assertion `VIRT_VIEWER_IS_DISPLAY(self)'
failed

This happens because VirtViewerWindow::display is NULL:

    G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args at entry=
    0x7fffffffd758) at gmessages.c:974
    log_level=<optimized out>, format=<optimized out>) at gmessages.c:1003
    at virt-viewer-display.c:634
    0x6e20c0 [VirtViewerWindow]) at virt-viewer-window.c:477
    0x6e20c0 [VirtViewerWindow]) at virt-viewer-window.c:1157
    0x6e00a0 [RemoteViewer]) at virt-viewer-app.c:1361
    at remote-viewer.c:674
    at virt-viewer-app.c:1374
    at remote-viewer-main.c:310

As most places in virt-viewer-window.c check for a NULL 'display'
before using it, let's do the same in
virt_viewer_window_move_to_monitor()
---
 src/virt-viewer-window.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index f8958a1..b2e7d82 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -472,9 +472,10 @@ virt_viewer_window_move_to_monitor(VirtViewerWindow *self)
 {
     VirtViewerWindowPrivate *priv = self->priv;
     GdkRectangle mon;
-    gint n;
+    gint n = -1;
 
-    n = virt_viewer_display_get_monitor(priv->display);
+    if (priv->display)
+        n = virt_viewer_display_get_monitor(priv->display);
     if (n == -1 || !priv->fullscreen)
         return;
 
-- 
1.8.1.4




More information about the virt-tools-list mailing list