From 7ef8d21e48438296da066111bdd4c98a5304fb14 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 18 Feb 2014 22:21:33 -0500 Subject: wayland: Allow destroying the wl_surface before the xdg_surface As resource destruction can happen in any order at shutdown, we need to be flexible here. A client disconnecting without cleaning up all its resources should not assert fail. --- src/wayland/meta-wayland-surface.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 10767cfff..e8777df95 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -596,11 +596,14 @@ meta_wayland_surface_window_unmanaged (MetaWaylandSurface *surface) static void destroy_window (MetaWaylandSurface *surface) { - MetaDisplay *display = meta_get_display (); - guint32 timestamp = meta_display_get_current_time_roundtrip (display); + if (surface->window) + { + MetaDisplay *display = meta_get_display (); + guint32 timestamp = meta_display_get_current_time_roundtrip (display); + + meta_window_unmanage (surface->window, timestamp); + } - g_assert (surface->window != NULL); - meta_window_unmanage (surface->window, timestamp); g_assert (surface->window == NULL); } @@ -610,11 +613,11 @@ wl_surface_destructor (struct wl_resource *resource) MetaWaylandSurface *surface = wl_resource_get_user_data (resource); MetaWaylandCompositor *compositor = surface->compositor; - /* At the time when the wl_surface is destroyed, we should - * no longer have a window, unless we're an XWayland window - * in which case we received the wl_surface.destroy before - * the UnmapNotify/DestroyNotify. */ - g_assert (surface->window == NULL || surface->window->client_type == META_WINDOW_CLIENT_TYPE_X11); + /* If we still have a window at the time of destruction, that means that + * the client is disconnecting, as the resources are destroyed in a random + * order. Simply destroy the window in this case. */ + if (surface->window) + destroy_window (surface); compositor->surfaces = g_list_remove (compositor->surfaces, surface); -- cgit v1.2.1