Merge pull request #2861 from RyanDwyer/fix-empty-workspace-crashes

Fix crashes when running certain commands on an empty workspace
This commit is contained in:
Drew DeVault 2018-10-17 16:13:05 +02:00 committed by GitHub
commit e46c3ffbc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -59,7 +59,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
} }
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;
if (!container->view) { if (!container || !container->view) {
return cmd_results_new(CMD_INVALID, "border", return cmd_results_new(CMD_INVALID, "border",
"Only views can have borders"); "Only views can have borders");
} }

View file

@ -19,7 +19,7 @@ struct cmd_results *cmd_mark(int argc, char **argv) {
return error; return error;
} }
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;
if (!container->view) { if (!container || !container->view) {
return cmd_results_new(CMD_INVALID, "mark", return cmd_results_new(CMD_INVALID, "mark",
"Only views can have marks"); "Only views can have marks");
} }

View file

@ -12,7 +12,7 @@ struct cmd_results *cmd_title_format(int argc, char **argv) {
return error; return error;
} }
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;
if (!container->view) { if (!container || !container->view) {
return cmd_results_new(CMD_INVALID, "title_format", return cmd_results_new(CMD_INVALID, "title_format",
"Only views can have a title_format"); "Only views can have a title_format");
} }

View file

@ -25,7 +25,7 @@ struct cmd_results *cmd_unmark(int argc, char **argv) {
struct sway_view *view = NULL; struct sway_view *view = NULL;
if (config->handler_context.using_criteria) { if (config->handler_context.using_criteria) {
struct sway_container *container = config->handler_context.container; struct sway_container *container = config->handler_context.container;
if (!container->view) { if (!container || !container->view) {
return cmd_results_new(CMD_INVALID, "unmark", return cmd_results_new(CMD_INVALID, "unmark",
"Only views can have marks"); "Only views can have marks");
} }