aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-31 18:52:02 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-31 18:52:02 -0400
commiteda425fdabb4050eb2ecc8741793d83e3a7bf154 (patch)
tree234918f83c38f0c494b8f0a04dff5704459bdbe6 /sway/tree/container.c
parentclean up view destroy seat cleanup (diff)
downloadsway-eda425fdabb4050eb2ecc8741793d83e3a7bf154.tar.gz
sway-eda425fdabb4050eb2ecc8741793d83e3a7bf154.tar.zst
sway-eda425fdabb4050eb2ecc8741793d83e3a7bf154.zip
fix some segfaults
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c19
1 files changed, 12 insertions, 7 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) {
69 if (cont->children != NULL) { 69 if (cont->children != NULL) {
70 // remove children until there are no more, container_destroy calls 70 // remove children until there are no more, container_destroy calls
71 // container_remove_child, which removes child from this container 71 // container_remove_child, which removes child from this container
72 while (cont->children->length != 0) { 72 while (cont->children != NULL && cont->children->length != 0) {
73 container_destroy(cont->children->items[0]); 73 struct sway_container *child = cont->children->items[0];
74 container_remove_child(child);
75 container_destroy(child);
74 } 76 }
75 list_free(cont->children);
76 cont->children = NULL;
77 } 77 }
78 if (cont->marks) { 78 if (cont->marks) {
79 list_foreach(cont->marks, free); 79 list_foreach(cont->marks, free);
@@ -85,13 +85,17 @@ static struct sway_container *_container_destroy(struct sway_container *cont) {
85 if (cont->name) { 85 if (cont->name) {
86 free(cont->name); 86 free(cont->name);
87 } 87 }
88 list_free(cont->children);
89 cont->children = NULL;
88 free(cont); 90 free(cont);
89 return parent; 91 return parent;
90} 92}
91 93
92struct sway_container *container_destroy(struct sway_container *cont) { 94struct sway_container *container_destroy(struct sway_container *cont) {
93 cont = _container_destroy(cont); 95 struct sway_container *parent = _container_destroy(cont);
94 return container_reap_empty(cont->parent); 96 parent = container_reap_empty(parent);
97 arrange_windows(&root_container, -1, -1);
98 return parent;
95} 99}
96 100
97struct sway_container *container_output_create( 101struct sway_container *container_output_create(
@@ -409,7 +413,8 @@ bool find_child_func(struct sway_container *con, void *data) {
409 413
410bool container_has_child(struct sway_container *con, 414bool container_has_child(struct sway_container *con,
411 struct sway_container *child) { 415 struct sway_container *child) {
412 if (child->type == C_VIEW || child->children->length == 0) { 416 if (child == NULL || child->type == C_VIEW ||
417 child->children->length == 0) {
413 return false; 418 return false;
414 } 419 }
415 return container_find(con, find_child_func, child); 420 return container_find(con, find_child_func, child);