1
1
mirror of https://github.com/swaywm/sway synced 2024-11-18 04:33:59 +01:00

Fix crash when moving last child of a container to workspace or output

We were arranging a parent which may have been deleted by the reaper,
which meant the `current` children list of the surviving parent had a
dangling pointer.

Instead, we now reap the workspace.
This commit is contained in:
Ryan Dwyer 2018-06-29 19:36:22 +10:00
parent 9652529cc1
commit e8fb6b3325

@ -90,6 +90,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
}
free(ws_name);
struct sway_container *old_parent = current->parent;
struct sway_container *old_ws = container_parent(current, C_WORKSPACE);
struct sway_container *destination = seat_get_focus_inactive(
config->handler_context.seat, ws);
container_move_to(current, destination);
@ -99,8 +100,11 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
container_reap_empty(old_parent);
container_reap_empty(destination->parent);
// TODO: Ideally we would arrange the surviving parent after reaping,
// but container_reap_empty does not return it, so we arrange the
// workspace instead.
struct sway_transaction *txn = transaction_create();
arrange_windows(old_parent, txn);
arrange_windows(old_ws, txn);
arrange_windows(destination->parent, txn);
transaction_commit(txn);
@ -129,13 +133,17 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
focus = destination->children->items[0];
}
struct sway_container *old_parent = current->parent;
struct sway_container *old_ws = container_parent(current, C_WORKSPACE);
container_move_to(current, focus);
seat_set_focus(config->handler_context.seat, old_parent);
container_reap_empty(old_parent);
container_reap_empty(focus->parent);
// TODO: Ideally we would arrange the surviving parent after reaping,
// but container_reap_empty does not return it, so we arrange the
// workspace instead.
struct sway_transaction *txn = transaction_create();
arrange_windows(old_parent, txn);
arrange_windows(old_ws, txn);
arrange_windows(focus->parent, txn);
transaction_commit(txn);