aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-03-31 18:52:02 -0400
committerTony Crisci <tony@dubstepdish.com>2018-03-31 18:52:02 -0400
commiteda425fdabb4050eb2ecc8741793d83e3a7bf154 (patch)
tree234918f83c38f0c494b8f0a04dff5704459bdbe6 /sway/tree
parent2aec85bf241f4bad59a23e8492e91d3e7add6ab6 (diff)
downloadsway-eda425fdabb4050eb2ecc8741793d83e3a7bf154.tar.xz
fix some segfaults
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c19
-rw-r--r--sway/tree/layout.c4
2 files changed, 14 insertions, 9 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index e2fe9e7c..b3c6d80f 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -69,11 +69,11 @@ static struct sway_container *_container_destroy(struct sway_container *cont) {
if (cont->children != NULL) {
// remove children until there are no more, container_destroy calls
// container_remove_child, which removes child from this container
- while (cont->children->length != 0) {
- container_destroy(cont->children->items[0]);
+ while (cont->children != NULL && cont->children->length != 0) {
+ struct sway_container *child = cont->children->items[0];
+ container_remove_child(child);
+ container_destroy(child);
}
- list_free(cont->children);
- cont->children = NULL;
}
if (cont->marks) {
list_foreach(cont->marks, free);
@@ -85,13 +85,17 @@ static struct sway_container *_container_destroy(struct sway_container *cont) {
if (cont->name) {
free(cont->name);
}
+ list_free(cont->children);
+ cont->children = NULL;
free(cont);
return parent;
}
struct sway_container *container_destroy(struct sway_container *cont) {
- cont = _container_destroy(cont);
- return container_reap_empty(cont->parent);
+ struct sway_container *parent = _container_destroy(cont);
+ parent = container_reap_empty(parent);
+ arrange_windows(&root_container, -1, -1);
+ return parent;
}
struct sway_container *container_output_create(
@@ -409,7 +413,8 @@ bool find_child_func(struct sway_container *con, void *data) {
bool container_has_child(struct sway_container *con,
struct sway_container *child) {
- if (child->type == C_VIEW || child->children->length == 0) {
+ if (child == NULL || child->type == C_VIEW ||
+ child->children->length == 0) {
return false;
}
return container_find(con, find_child_func, child);
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 62df19e9..5098c8d1 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -106,11 +106,11 @@ void container_add_child(struct sway_container *parent,
}
struct sway_container *container_reap_empty(struct sway_container *container) {
- if (!sway_assert(container, "reaping null container")) {
+ if (container == NULL) {
return NULL;
}
wlr_log(L_DEBUG, "reaping %p %s", container, container->name);
- while (container != &root_container && container->children->length == 0) {
+ while (container->type != C_VIEW && container != &root_container && container->children->length == 0) {
if (container->type == C_WORKSPACE) {
if (!workspace_is_visible(container)) {
struct sway_container *parent = container->parent;