aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-05-10 11:01:33 +0100
committerGitHub <noreply@github.com>2018-05-10 11:01:33 +0100
commit8fd58ce72575df0f4cd96bffe55e4eeb04227f18 (patch)
tree6d5074dd54781a4114bf97b9bb9a684455430db5
parentf520dd8fac7a92ebe8dc2fc678a2690692ae6252 (diff)
parent72a75b3a72ca79f0045b43b1ba11feda08a8de3b (diff)
Merge pull request #967 from VincentVanlaer/xwayland-crash
Fix Xwayland cleanup
-rw-r--r--include/wlr/xwayland.h2
-rw-r--r--xwayland/xwayland.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index 3507e547..7471bbc6 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -16,7 +16,6 @@ struct wlr_xwayland {
struct wl_client *client;
struct wl_event_source *sigusr1_source;
struct wl_listener client_destroy;
- struct wl_listener display_destroy;
struct wlr_xwm *xwm;
struct wlr_xwayland_cursor *cursor;
int wm_fd[2], wl_fd[2];
@@ -28,6 +27,7 @@ struct wlr_xwayland {
int display;
int x_fd[2];
struct wl_event_source *x_fd_read_event[2];
+ struct wl_listener display_destroy;
bool lazy;
diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c
index 22d5cdeb..51035f0e 100644
--- a/xwayland/xwayland.c
+++ b/xwayland/xwayland.c
@@ -133,6 +133,13 @@ static void xwayland_finish_server(struct wlr_xwayland *wlr_xwayland) {
return;
}
+ if (wlr_xwayland->x_fd_read_event[0]) {
+ wl_event_source_remove(wlr_xwayland->x_fd_read_event[0]);
+ wl_event_source_remove(wlr_xwayland->x_fd_read_event[1]);
+
+ wlr_xwayland->x_fd_read_event[0] = wlr_xwayland->x_fd_read_event[1] = NULL;
+ }
+
if (wlr_xwayland->cursor != NULL) {
free(wlr_xwayland->cursor);
}
@@ -162,6 +169,10 @@ static void xwayland_finish_server(struct wlr_xwayland *wlr_xwayland) {
}
static void xwayland_finish_display(struct wlr_xwayland *wlr_xwayland) {
+ if (!wlr_xwayland || wlr_xwayland->display == -1) {
+ return;
+ }
+
safe_close(wlr_xwayland->x_fd[0]);
safe_close(wlr_xwayland->x_fd[1]);
wlr_xwayland->x_fd[0] = wlr_xwayland->x_fd[1] = -1;