From d3d7956576341bbbfb60d045175b0e8a44752e0b Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 21 Feb 2019 13:24:13 -0500 Subject: Handle NULL from output_get_active_workspace This modifies the places where output_get_active_workspace is called to handle a NULL result. Some places already handled it and did not need a change, some just have guard off code blocks, others return errors, and some have sway_asserts since the case should never happen. A lot of this is probably just safety precautions since they probably will never be called when `output_get_active_workspace` is not fully configured with a workspace. --- sway/tree/container.c | 2 +- sway/tree/output.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'sway/tree') diff --git a/sway/tree/container.c b/sway/tree/container.c index 9358dad7..933907f4 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -831,7 +831,7 @@ void container_floating_move_to(struct sway_container *con, } struct sway_workspace *new_workspace = output_get_active_workspace(new_output); - if (old_workspace != new_workspace) { + if (new_workspace && old_workspace != new_workspace) { container_detach(con); workspace_add_floating(new_workspace, con); arrange_workspace(old_workspace); diff --git a/sway/tree/output.c b/sway/tree/output.c index 146bc423..e0a66e0b 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -143,6 +143,9 @@ void output_enable(struct sway_output *output, struct output_config *oc) { static void evacuate_sticky(struct sway_workspace *old_ws, struct sway_output *new_output) { struct sway_workspace *new_ws = output_get_active_workspace(new_output); + if (!sway_assert(new_ws, "New output does not have a workspace")) { + return; + } while (old_ws->floating->length) { struct sway_container *sticky = old_ws->floating->items[0]; container_detach(sticky); -- cgit v1.2.3-54-g00ecf