ipc: handle NULL cases for node_get_output

master
Ian Fan 6 years ago
parent 1c292fd43a
commit 34dbbb1314

@ -316,9 +316,12 @@ static void focus_inactive_children_iterator(struct sway_node *node,
struct focus_inactive_data *data = _data; struct focus_inactive_data *data = _data;
json_object *focus = data->object; json_object *focus = data->object;
if (data->node == &root->node) { if (data->node == &root->node) {
int len = json_object_array_length(focus);
struct sway_output *output = node_get_output(node); struct sway_output *output = node_get_output(node);
if (output == NULL) {
return;
}
size_t id = output->node.id; size_t id = output->node.id;
int len = json_object_array_length(focus);
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
if ((size_t) json_object_get_int(json_object_array_get_idx(focus, i)) == id) { if ((size_t) json_object_get_int(json_object_array_get_idx(focus, i)) == id) {
return; return;

@ -74,8 +74,10 @@ void node_get_box(struct sway_node *node, struct wlr_box *box) {
struct sway_output *node_get_output(struct sway_node *node) { struct sway_output *node_get_output(struct sway_node *node) {
switch (node->type) { switch (node->type) {
case N_CONTAINER: case N_CONTAINER: {
return node->sway_container->workspace->output; struct sway_workspace *ws = node->sway_container->workspace;
return ws ? ws->output : NULL;
}
case N_WORKSPACE: case N_WORKSPACE:
return node->sway_workspace->output; return node->sway_workspace->output;
case N_OUTPUT: case N_OUTPUT:

Loading…
Cancel
Save