mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
wayland-surface: Don't crash if a client destroys a buffer in use
This is considered "undefined" by upstream. Right now GTK+ does this a lot, so we shouldn't crash. Let's make them crash instead and send them an error instead.
This commit is contained in:
parent
0a9754f305
commit
3e98ffaf99
@ -71,6 +71,17 @@ typedef struct
|
||||
struct wl_listener sibling_destroy_listener;
|
||||
} MetaWaylandSubsurfacePlacementOp;
|
||||
|
||||
static void
|
||||
surface_handle_buffer_destroy (struct wl_listener *listener, void *data)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_container_of (listener, surface, buffer_destroy_listener);
|
||||
|
||||
wl_resource_post_error (surface->resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||
"Destroyed buffer while it was attached to the surface");
|
||||
surface->buffer = NULL;
|
||||
wl_list_remove (&surface->buffer_destroy_listener.link);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_set_buffer (MetaWaylandSurface *surface,
|
||||
MetaWaylandBuffer *buffer)
|
||||
@ -79,12 +90,18 @@ surface_set_buffer (MetaWaylandSurface *surface,
|
||||
return;
|
||||
|
||||
if (surface->buffer)
|
||||
meta_wayland_buffer_unref (surface->buffer);
|
||||
{
|
||||
meta_wayland_buffer_unref (surface->buffer);
|
||||
wl_list_remove (&surface->buffer_destroy_listener.link);
|
||||
}
|
||||
|
||||
surface->buffer = buffer;
|
||||
|
||||
if (surface->buffer)
|
||||
meta_wayland_buffer_ref (surface->buffer);
|
||||
{
|
||||
meta_wayland_buffer_ref (surface->buffer);
|
||||
wl_signal_add (&surface->buffer->destroy_signal, &surface->buffer_destroy_listener);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -621,6 +638,8 @@ meta_wayland_surface_create (MetaWaylandCompositor *compositor,
|
||||
|
||||
double_buffered_state_init (&surface->pending);
|
||||
|
||||
surface->buffer_destroy_listener.notify = surface_handle_buffer_destroy;
|
||||
|
||||
surface->surface_actor = g_object_ref_sink (meta_surface_actor_new ());
|
||||
return surface;
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ struct _MetaWaylandSurface
|
||||
{
|
||||
struct wl_resource *resource;
|
||||
MetaWaylandCompositor *compositor;
|
||||
MetaWaylandBuffer *buffer;
|
||||
MetaSurfaceActor *surface_actor;
|
||||
MetaWindow *window;
|
||||
MetaWaylandSurfaceExtension xdg_surface;
|
||||
@ -79,6 +78,9 @@ struct _MetaWaylandSurface
|
||||
MetaWaylandSurfaceExtension gtk_surface;
|
||||
MetaWaylandSurfaceExtension subsurface;
|
||||
|
||||
MetaWaylandBuffer *buffer;
|
||||
struct wl_listener buffer_destroy_listener;
|
||||
|
||||
GList *subsurfaces;
|
||||
|
||||
struct {
|
||||
|
Loading…
Reference in New Issue
Block a user