GNOME Bugzilla – Bug 735830
Pixmap based cursors get surface destroyed after first use
Last modified: 2014-09-01 18:49:06 UTC
When a pixmap-based cursor is set as the current cursor, its wl_buffer goes through the same general machinery than GdkWindow wl_buffers do, which does call cairo_surface_destroy on buffer_release_callback(). These cursors don't account for its only surface reference to be dropped elsewhere, and crashes happen when the cursor gets reused (eg. setting another cursor, and that one back). I'm attaching a patch that adds a reference to the cairo surface before handing the wl_buffer for rendering, so it behaves similarly to GdkWindows there.
Created attachment 285040 [details] [review] wayland: Reference pixmap-based cursors' surface before handing the wl_buffer cairo_surface_destroy() is called after the buffer is released, for every wl_buffer. Windows usually reference their cairo surface before rendering, so that extra reference is consumed after the buffer is released, so do the same with cursor surfaces and add an extra reference whenever a cursor surface change is about to be scheduled. Otherwise, the GdkWaylandCursor is left with an invalid cairo_surface_t, which causes crashes the next time it is used.
Review of attachment 285040 [details] [review]: good catch
Attachment 285040 [details] pushed as a0abdbb - wayland: Reference pixmap-based cursors' surface before handing the wl_buffer