diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-08-31 11:55:12 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-08-31 11:55:12 -0400 |
commit | aec47b823880c7dc80f63569103e29c5ebca2f22 (patch) | |
tree | b661ce2e2d2cac06294a7a7ac9e84e4ab24abbca | |
parent | Merge pull request #156 from Luminarys/master (diff) | |
parent | properly remove children in loops (diff) | |
download | sway-aec47b823880c7dc80f63569103e29c5ebca2f22.tar.gz sway-aec47b823880c7dc80f63569103e29c5ebca2f22.tar.zst sway-aec47b823880c7dc80f63569103e29c5ebca2f22.zip |
Merge pull request #158 from taiyu-len/master
properly remove children in loops
-rw-r--r-- | sway/container.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sway/container.c b/sway/container.c index d60aa6ff..442266ec 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -35,11 +35,8 @@ static void free_swayc(swayc_t *cont) { | |||
35 | list_free(cont->children); | 35 | list_free(cont->children); |
36 | } | 36 | } |
37 | if (cont->floating) { | 37 | if (cont->floating) { |
38 | if (cont->floating->length) { | 38 | while (cont->floating->length) { |
39 | int i; | 39 | free_swayc(cont->floating->items[0]); |
40 | for (i = 0; i < cont->floating->length; ++i) { | ||
41 | free_swayc(cont->floating->items[i]); | ||
42 | } | ||
43 | } | 40 | } |
44 | list_free(cont->floating); | 41 | list_free(cont->floating); |
45 | } | 42 | } |
@@ -304,16 +301,14 @@ swayc_t *destroy_output(swayc_t *output) { | |||
304 | return NULL; | 301 | return NULL; |
305 | } | 302 | } |
306 | if (output->children->length > 0) { | 303 | if (output->children->length > 0) { |
307 | int i, len = root_container.children->length; | ||
308 | // TODO save workspaces when there are no outputs. | 304 | // TODO save workspaces when there are no outputs. |
309 | // TODO also check if there will ever be no outputs except for exiting | 305 | // TODO also check if there will ever be no outputs except for exiting |
310 | // program | 306 | // program |
311 | if (len > 1) { | 307 | if (root_container.children->length > 1) { |
312 | len = output->children->length; | ||
313 | int p = root_container.children->items[0] == output; | 308 | int p = root_container.children->items[0] == output; |
314 | // Move workspace from this output to another output | 309 | // Move workspace from this output to another output |
315 | for (i = 0; i < len; ++i) { | 310 | while (output->children->length) { |
316 | swayc_t *child = output->children->items[i]; | 311 | swayc_t *child = output->children->items[0]; |
317 | remove_child(child); | 312 | remove_child(child); |
318 | add_child(root_container.children->items[p], child); | 313 | add_child(root_container.children->items[p], child); |
319 | } | 314 | } |
@@ -651,6 +646,7 @@ void update_visibility(swayc_t *container) { | |||
651 | } | 646 | } |
652 | 647 | ||
653 | void reset_gaps(swayc_t *view, void *data) { | 648 | void reset_gaps(swayc_t *view, void *data) { |
649 | (void) data; | ||
654 | if (!ASSERT_NONNULL(view)) { | 650 | if (!ASSERT_NONNULL(view)) { |
655 | return; | 651 | return; |
656 | } | 652 | } |