diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-24 15:50:53 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-24 15:50:53 +1000 |
commit | b864ac0149212adf753824366e20badfa971b29f (patch) | |
tree | 87f9a4117a84d3552c25a2434094d221c7d6bad0 /sway/commands | |
parent | Fix crash related to stacks and tabs (diff) | |
download | sway-b864ac0149212adf753824366e20badfa971b29f.tar.gz sway-b864ac0149212adf753824366e20badfa971b29f.tar.zst sway-b864ac0149212adf753824366e20badfa971b29f.zip |
Fix crash when unmapping a view with reapable parents
container_destroy was calling container_reap_empty, which calls
container_destroy and so on. Eventually the original container_destroy
would return a NULL pointer to the caller which caused a crash.
This also fixes an arrange on the wrong container when moving views in
and out of stacks.
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/move.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 2c9fb77a..da0f89e9 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -177,13 +177,19 @@ static struct cmd_results *cmd_move_workspace(struct sway_container *current, | |||
177 | 177 | ||
178 | static void move_in_direction(struct sway_container *container, | 178 | static void move_in_direction(struct sway_container *container, |
179 | enum wlr_direction direction, int move_amt) { | 179 | enum wlr_direction direction, int move_amt) { |
180 | struct sway_container *old_parent = container->parent; | 180 | // For simplicity, we'll arrange the entire workspace. The reason for this |
181 | // is moving the container might reap the old parent, and container_move | ||
182 | // does not return a surviving parent. | ||
183 | // TODO: Make container_move return the surviving parent so we can arrange | ||
184 | // just that. | ||
185 | struct sway_container *old_ws = container_parent(container, C_WORKSPACE); | ||
181 | container_move(container, direction, move_amt); | 186 | container_move(container, direction, move_amt); |
187 | struct sway_container *new_ws = container_parent(container, C_WORKSPACE); | ||
182 | 188 | ||
183 | struct sway_transaction *txn = transaction_create(); | 189 | struct sway_transaction *txn = transaction_create(); |
184 | arrange_windows(old_parent, txn); | 190 | arrange_windows(old_ws, txn); |
185 | if (container->parent != old_parent) { | 191 | if (new_ws != old_ws) { |
186 | arrange_windows(container->parent, txn); | 192 | arrange_windows(new_ws, txn); |
187 | } | 193 | } |
188 | transaction_commit(txn); | 194 | transaction_commit(txn); |
189 | } | 195 | } |