From 8d0ee4811b3d15e98ce879ed5c68562357bfab86 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sun, 6 Aug 2023 09:47:37 +0200 Subject: [PATCH] Fix crash when using _ToEdge actions when using the default keybinds This happens because of two separate bugs: - The action validation failed to verify the data type of the argument - When adding the fallback keybinds we add them as string but expect them being an int This commit fixes the first bug. Fixes 1ee8715d57ddb6b444e0b089879db6f837400539 actions: use enum for _ToEdge actions --- src/action.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/action.c b/src/action.c index 900dcffc..35a29e7f 100644 --- a/src/action.c +++ b/src/action.c @@ -257,13 +257,13 @@ action_str_from_arg(struct action_arg *arg) } static bool -arg_value_exists(struct action *action, const char *key) +arg_value_exists(struct action *action, const char *key, enum action_arg_type type) { assert(action); assert(key); struct action_arg *arg; wl_list_for_each(arg, &action->args, link) { - if (!strcasecmp(key, arg->key)) { + if (!strcasecmp(key, arg->key) && arg->type == type) { return true; } } @@ -373,6 +373,8 @@ bool action_is_valid(struct action *action) { const char *arg_name = NULL; + enum action_arg_type arg_type = LAB_ACTION_ARG_STR; + switch (action->type) { case ACTION_TYPE_EXECUTE: arg_name = "command"; @@ -380,6 +382,7 @@ action_is_valid(struct action *action) case ACTION_TYPE_MOVE_TO_EDGE: case ACTION_TYPE_SNAP_TO_EDGE: arg_name = "direction"; + arg_type = LAB_ACTION_ARG_INT; break; case ACTION_TYPE_SHOW_MENU: arg_name = "menu"; @@ -399,7 +402,7 @@ action_is_valid(struct action *action) return true; } - if (arg_value_exists(action, arg_name)) { + if (arg_value_exists(action, arg_name, arg_type)) { return true; } -- 2.52.0