[Spice-commits] src/spice-widget.c

Pavel Grunt pgrunt at kemper.freedesktop.org
Mon May 29 06:42:40 UTC 2017


 src/spice-widget.c |   37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

New commits:
commit c3ee2cd0b32d286ca14678e9d6e12372571f7237
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Fri May 26 16:39:49 2017 +0200

    widget: Return early on cursor set without shape
    
    A cursor pixbuf is required in other functions to work properly
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index d42924b..1a1d5a6 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2643,26 +2643,27 @@ static void cursor_set(SpiceCursorChannel *channel,
     GdkCursor *cursor = NULL;
     SpiceCursorShape *cursor_shape;
 
-    cursor_invalidate(display);
-
     g_object_get(G_OBJECT(channel), "cursor", &cursor_shape, NULL);
-    if (cursor_shape != NULL && cursor_shape->data != NULL) {
-        g_clear_object(&d->mouse_pixbuf);
-        d->mouse_pixbuf = gdk_pixbuf_new_from_data(cursor_shape->data,
-                                                   GDK_COLORSPACE_RGB,
-                                                   TRUE, 8,
-                                                   cursor_shape->width,
-                                                   cursor_shape->height,
-                                                   cursor_shape->width * 4,
-                                                   NULL, NULL);
-        d->mouse_hotspot.x = cursor_shape->hot_spot_x;
-        d->mouse_hotspot.y = cursor_shape->hot_spot_y;
-        cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(GTK_WIDGET(display)),
-                                            d->mouse_pixbuf,
-                                            d->mouse_hotspot.x,
-                                            d->mouse_hotspot.y);
-    } else
+    if (G_UNLIKELY(cursor_shape == NULL || cursor_shape->data == NULL)) {
         g_warn_if_reached();
+        return;
+    }
+
+    cursor_invalidate(display);
+    g_clear_object(&d->mouse_pixbuf);
+    d->mouse_pixbuf = gdk_pixbuf_new_from_data(cursor_shape->data,
+                                               GDK_COLORSPACE_RGB,
+                                               TRUE, 8,
+                                               cursor_shape->width,
+                                               cursor_shape->height,
+                                               cursor_shape->width * 4,
+                                               NULL, NULL);
+    d->mouse_hotspot.x = cursor_shape->hot_spot_x;
+    d->mouse_hotspot.y = cursor_shape->hot_spot_y;
+    cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(GTK_WIDGET(display)),
+                                        d->mouse_pixbuf,
+                                        d->mouse_hotspot.x,
+                                        d->mouse_hotspot.y);
 
 #if HAVE_EGL
     if (egl_enabled(d))


More information about the Spice-commits mailing list