From 8aedc042eeaa95a7a0be7c1dd06e3739ee1c7bd4 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 31 Mar 2018 13:47:22 -0400 Subject: [PATCH] Fix two segfaults when destroying outputs --- sway/desktop/layer_shell.c | 5 +++-- sway/tree/layout.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 5c96659a1..c18f51c71 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -238,11 +238,12 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&sway_layer->unmap.link); wl_list_remove(&sway_layer->surface_commit.link); if (sway_layer->layer_surface->output != NULL) { + struct sway_output *output = sway_layer->layer_surface->output->data; + arrange_layers(output); + wl_list_remove(&sway_layer->output_destroy.link); } - struct sway_output *output = sway_layer->layer_surface->output->data; free(sway_layer); - arrange_layers(output); } static void handle_map(struct wl_listener *listener, void *data) { diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 588ceb2db..ce0682dc9 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -107,7 +107,7 @@ struct sway_container *container_reap_empty(struct sway_container *container) { return NULL; } wlr_log(L_DEBUG, "reaping %p %s", container, container->name); - while (container->children->length == 0) { + while (container != &root_container && container->children->length == 0) { if (container->type == C_WORKSPACE) { if (!workspace_is_visible(container)) { struct sway_container *parent = container->parent;