[gtk+] wayland: Avoid segfault when cursors are freed



commit 37843faea9e67cb3bfe8dfb11c76e8dd78b876c7
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Mar 22 19:09:20 2013 -0400

    wayland: Avoid segfault when cursors are freed
    
    The check for GDK_CURSOR_IS_PIXMAP was ineffective, since _all_
    cursors have this type, from the looks of it. Instead, store
    buffer ownership information separately.

 gdk/wayland/gdkcursor-wayland.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c
index 76d3708..a8df766 100644
--- a/gdk/wayland/gdkcursor-wayland.c
+++ b/gdk/wayland/gdkcursor-wayland.c
@@ -54,6 +54,7 @@ struct _GdkWaylandCursor
   int hotspot_x, hotspot_y;
   int width, height;
   struct wl_buffer *buffer;
+  gboolean free_buffer;
 };
 
 struct _GdkWaylandCursorClass
@@ -133,7 +134,7 @@ gdk_wayland_cursor_finalize (GObject *object)
   GdkWaylandCursor *cursor = GDK_WAYLAND_CURSOR (object);
 
   g_free (cursor->name);
-  if (cursor->cursor.type == GDK_CURSOR_IS_PIXMAP)
+  if (cursor->free_buffer)
     wl_buffer_destroy (cursor->buffer);
 
   G_OBJECT_CLASS (_gdk_wayland_cursor_parent_class)->finalize (object);
@@ -311,6 +312,7 @@ _gdk_wayland_display_get_cursor_for_name (GdkDisplay  *display,
   private->height = cursor->images[0]->height;
 
   private->buffer = wl_cursor_image_get_buffer(cursor->images[0]);
+  private->free_buffer = FALSE;
 
   add_to_cache (wayland_display, private);
 
@@ -372,6 +374,7 @@ _gdk_wayland_display_get_cursor_for_pixbuf (GdkDisplay *display,
                                        cursor->height,
                                        stride,
                                        WL_SHM_FORMAT_ARGB8888);
+  cursor->free_buffer = FALSE;
 
   wl_shm_pool_destroy (pool);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]