From f4f44d88fe4a01764687226e9ad74495959a8aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 15 Aug 2019 19:12:08 +0200 Subject: [PATCH] modules/sway-xkb: never *update* state without locking it --- modules/sway_xkb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/sway_xkb.c b/modules/sway_xkb.c index 7e0040f..9350d84 100644 --- a/modules/sway_xkb.c +++ b/modules/sway_xkb.c @@ -104,9 +104,9 @@ handle_input_reply(int type, const struct json_object *json, void *_mod) struct input *maybe_input = &m->inputs[i]; if (strcmp(maybe_input->identifier, id) == 0) { input = maybe_input; - input->exists = true; mtx_lock(&mod->lock); + input->exists = true; m->num_existing_inputs++; mtx_unlock(&mod->lock); break; @@ -184,10 +184,11 @@ handle_input_event(int type, const struct json_object *json, void *_mod) mtx_lock(&mod->lock); assert((is_removed && input->exists) || (is_added && !input->exists)); - input->exists = !input->exists; + input->exists = !input->exists; m->num_existing_inputs += is_added ? 1 : -1; m->dirty = true; + mtx_unlock(&mod->lock); if (is_removed)