[Spice-commits] 2 commits - src/channel-webdav.c src/spice-widget.c

Pavel Grunt pgrunt at kemper.freedesktop.org
Thu Jul 28 18:01:02 UTC 2016


 src/channel-webdav.c |    4 ++--
 src/spice-widget.c   |   36 +++++++++++++++++++++++-------------
 2 files changed, 25 insertions(+), 15 deletions(-)

New commits:
commit 85a96f881b72a89fbe301a20565717bf929d3af2
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Thu Jul 28 18:55:11 2016 +0200

    webdav: Do not reuse cancellable
    
    Create it on SPICE_PORT_EVENT_OPENED
    
    From g_cancellable_reset documentation:
     Note that it is generally not a good idea to reuse an existing
     cancellable for more operations after it has been cancelled once,
     as this function might tempt you to do. The recommended practice is
     to drop the reference to a cancellable after cancelling it, and let it
     die with the outstanding async operations. You should create a fresh
     cancellable for further async operations
    
    In our case reusing the cancellable leads to a crash:
     #0  0x00007ffff1662940 in g_task_return_error () at /lib64/libgio-2.0.so.0
     #1  0x00007ffff1662b60 in g_task_return_new_error () at /lib64/libgio-2.0.so.0
     #2  0x00007ffff57916e0 in read_cancelled (cancellable=<optimized out>, user_data=<optimized out>) at vmcstream.c:182
     #3  0x00007ffff1391555 in g_closure_invoke () at /lib64/libgobject-2.0.so.0
     #4  0x00007ffff13a4062 in signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
     #5  0x00007ffff13acf5f in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
     #6  0x00007ffff13ad33f in g_signal_emit () at /lib64/libgobject-2.0.so.0
     #7  0x00007ffff16100d8 in g_cancellable_cancel () at /lib64/libgio-2.0.so.0
     #8  0x00007ffff5775c01 in port_event (self=0xc7af60, event=1) at channel-webdav.c:512
     #9  0x00007ffff1391555 in g_closure_invoke () at /lib64/libgobject-2.0.so.0
     #10 0x00007ffff13a445d in signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
     #11 0x00007ffff13acf5f in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
     #12 0x00007ffff577479a in emit_main_context (opaque=0x7fffa5fff8d0) at gio-coroutine.c:200
     #13 0x00007ffff10b7847 in g_idle_dispatch () at /lib64/libglib-2.0.so.0
     #14 0x00007ffff10bade2 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
     #15 0x00007ffff10bb160 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
     #16 0x00007ffff10bb20c in g_main_context_iteration () at /lib64/libglib-2.0.so.0
     #17 0x00007ffff1677d2d in g_application_run () at /lib64/libgio-2.0.so.0
     #18 0x000000000041031a in main (argc=2, argv=0x7fffffffd928) at remote-viewer-main.c:42
    
    Fixes:
    https://bugs.freedesktop.org/show_bug.cgi?id=97113

diff --git a/src/channel-webdav.c b/src/channel-webdav.c
index 307a867..0a2ed72 100644
--- a/src/channel-webdav.c
+++ b/src/channel-webdav.c
@@ -506,7 +506,8 @@ static void port_event(SpiceWebdavChannel *self, gint event)
 
     CHANNEL_DEBUG(self, "port event:%d", event);
     if (event == SPICE_PORT_EVENT_OPENED) {
-        g_cancellable_reset(c->cancellable);
+        g_clear_object(&c->cancellable);
+        c->cancellable = g_cancellable_new();
         start_demux(self);
     } else {
         g_cancellable_cancel(c->cancellable);
@@ -529,7 +530,6 @@ static void spice_webdav_channel_init(SpiceWebdavChannel *channel)
 
     channel->priv = c;
     c->stream = spice_vmc_stream_new(SPICE_CHANNEL(channel));
-    c->cancellable = g_cancellable_new();
     c->clients = g_hash_table_new_full(g_int64_hash, g_int64_equal,
                                        NULL, client_remove_unref);
     c->demux.buf = g_malloc0(MAX_MUX_SIZE);
commit a395ac59447dedfb922f997c7c9cff93edd53600
Author: Lukas Venhoda <lvenhoda at redhat.com>
Date:   Thu Jul 28 15:51:30 2016 +0200

    spice-widget: init egl only after first gl_scanout
    
    When using GtkDrawingArea and EGL was not used, it was still initialized.
    This produced warning messages on systems where EGL is not supported.
    
    Move spice_egl_init from drawing_area_realize to gl_scanout.
    
    Fixes:
    https://bugs.freedesktop.org/show_bug.cgi?id=95254

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 9020b07..7c1c756 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -568,20 +568,11 @@ drawing_area_realize(GtkWidget *area, gpointer user_data)
 {
 #ifdef GDK_WINDOWING_X11
     SpiceDisplay *display = SPICE_DISPLAY(user_data);
-    GError *err = NULL;
 
-    if (!GDK_IS_X11_DISPLAY(gdk_display_get_default()))
-        return;
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default()) &&
+        spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(display->priv->display)) != NULL)
+        spice_display_widget_gl_scanout(display);
 
-    if (!spice_egl_init(display, &err)) {
-        g_critical("egl init failed: %s", err->message);
-        g_clear_error(&err);
-    }
-
-    if (!spice_egl_realize_display(display, gtk_widget_get_window(area), &err)) {
-        g_critical("egl realize failed: %s", err->message);
-        g_clear_error(&err);
-    }
 #endif
 }
 
@@ -2662,13 +2653,32 @@ G_GNUC_INTERNAL
 void spice_display_widget_gl_scanout(SpiceDisplay *display)
 {
     SpiceDisplayPrivate *d = display->priv;
+    GError *err = NULL;
 
     SPICE_DEBUG("%s: got scanout",  __FUNCTION__);
+
+#ifdef GDK_WINDOWING_X11
+    GtkWidget *area = gtk_stack_get_child_by_name(d->stack, "draw-area");
+
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default()) &&
+        !d->egl.context_ready &&
+        gtk_widget_get_realized(area)) {
+        if (!spice_egl_init(display, &err)) {
+            g_critical("egl init failed: %s", err->message);
+            g_clear_error(&err);
+        }
+
+        if (!spice_egl_realize_display(display, gtk_widget_get_window(area), &err)) {
+            g_critical("egl realize failed: %s", err->message);
+            g_clear_error(&err);
+        }
+    }
+#endif
+
     set_egl_enabled(display, true);
 
     if (d->egl.context_ready) {
         const SpiceGlScanout *scanout;
-        GError *err = NULL;
 
         scanout = spice_display_get_gl_scanout(SPICE_DISPLAY_CHANNEL(d->display));
         /* should only be called when the display has a scanout */


More information about the Spice-commits mailing list