From b06535718dd61d99ca904e4dbb503b8857456c46 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 8 Dec 2017 01:38:45 +0100 Subject: Do not destroy wl_client in wlr_xwayland_finish --- xwayland/xwayland.c | 53 +++++++++++++++++++++++++++++------------------------ xwayland/xwm.c | 9 +++++++++ 2 files changed, 38 insertions(+), 24 deletions(-) (limited to 'xwayland') diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 778b959d..a4b79e73 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -125,39 +125,26 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) { execvp("Xwayland", argv); } -static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, - struct wl_display *wl_display, struct wlr_compositor *compositor); -static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland); - -static void xwayland_destroy_event(struct wl_listener *listener, void *data) { - struct wlr_xwayland *wlr_xwayland = wl_container_of(listener, wlr_xwayland, destroy_listener); - - /* don't call client destroy */ - wlr_xwayland->client = NULL; - wl_list_remove(&wlr_xwayland->destroy_listener.link); - wlr_xwayland_finish(wlr_xwayland); - - if (time(NULL) - wlr_xwayland->server_start > 5) { - wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display, - wlr_xwayland->compositor); - } -} - static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) { if (!wlr_xwayland || wlr_xwayland->display == -1) { return; } + if (wlr_xwayland->cursor != NULL) { + free(wlr_xwayland->cursor); + } + + xwm_destroy(wlr_xwayland->xwm); + if (wlr_xwayland->client) { - wl_list_remove(&wlr_xwayland->destroy_listener.link); - wl_client_destroy(wlr_xwayland->client); + wl_list_remove(&wlr_xwayland->client_destroy.link); + // TODO: this segfaults in /usr/lib/libEGL_mesa.so.0 + //wl_client_destroy(wlr_xwayland->client); } if (wlr_xwayland->sigusr1_source) { wl_event_source_remove(wlr_xwayland->sigusr1_source); } - xwm_destroy(wlr_xwayland->xwm); - safe_close(wlr_xwayland->x_fd[0]); safe_close(wlr_xwayland->x_fd[1]); safe_close(wlr_xwayland->wl_fd[0]); @@ -176,6 +163,24 @@ static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland) { */ } +static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, + struct wl_display *wl_display, struct wlr_compositor *compositor); + +static void handle_client_destroy(struct wl_listener *listener, void *data) { + struct wlr_xwayland *wlr_xwayland = + wl_container_of(listener, wlr_xwayland, client_destroy); + + /* don't call client destroy */ + wlr_xwayland->client = NULL; + wl_list_remove(&wlr_xwayland->client_destroy.link); + wlr_xwayland_finish(wlr_xwayland); + + if (time(NULL) - wlr_xwayland->server_start > 5) { + wlr_xwayland_init(wlr_xwayland, wlr_xwayland->wl_display, + wlr_xwayland->compositor); + } +} + static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_xwayland *wlr_xwayland = wl_container_of(listener, wlr_xwayland, display_destroy); @@ -264,9 +269,9 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, wlr_xwayland->wl_fd[0] = -1; /* not ours anymore */ - wlr_xwayland->destroy_listener.notify = xwayland_destroy_event; + wlr_xwayland->client_destroy.notify = handle_client_destroy; wl_client_add_destroy_listener(wlr_xwayland->client, - &wlr_xwayland->destroy_listener); + &wlr_xwayland->client_destroy); struct wl_event_loop *loop = wl_display_get_event_loop(wl_display); wlr_xwayland->sigusr1_source = wl_event_loop_add_signal(loop, SIGUSR1, diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 562f2052..3250a97d 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1045,6 +1045,12 @@ void xwm_destroy(struct wlr_xwm *xwm) { if (xwm->cursor) { xcb_free_cursor(xwm->xcb_conn, xwm->cursor); } + if (xwm->colormap) { + xcb_free_colormap(xwm->xcb_conn, xwm->colormap); + } + if (xwm->window) { + xcb_destroy_window(xwm->xcb_conn, xwm->window); + } if (xwm->event_source) { wl_event_source_remove(xwm->event_source); } @@ -1052,6 +1058,9 @@ void xwm_destroy(struct wlr_xwm *xwm) { wl_list_for_each_safe(xsurface, tmp, &xwm->surfaces, link) { wlr_xwayland_surface_destroy(xsurface); } + wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) { + wlr_xwayland_surface_destroy(xsurface); + } wl_list_remove(&xwm->compositor_surface_create.link); xcb_disconnect(xwm->xcb_conn); -- cgit v1.2.3