wayland/cursor-role: Handle premature wl_buffer destruction

If a client would attach a buffer to a surface, commit, destroy the
buffer and then later set the surface as a cursor, there will be no
wl_buffer available to be used by the cursor role. Instead of
dereferencing the non-existing wl_buffer resource, handle this situation
by logging a warning and treating a prematurely destroyd wl_buffer as if
no buffer had been attached.

https://bugzilla.gnome.org/show_bug.cgi?id=770992
This commit is contained in:
Jonas Ådahl 2016-09-07 16:23:25 +08:00
parent 2e7f11305c
commit 640178a94f

View File

@ -230,9 +230,11 @@ cursor_surface_role_constructed (GObject *object)
MetaWaylandBuffer *buffer;
buffer = meta_wayland_surface_get_buffer (surface);
if (buffer)
g_warn_if_fail (!buffer || buffer->resource);
if (buffer && buffer->resource)
{
g_assert (buffer->resource);
g_set_object (&priv->buffer, buffer);
meta_wayland_surface_ref_buffer_use_count (surface);
}