From da15317ac2e299f3c1b3833b2c5b198d2d7df5ab Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 6 Dec 2014 11:14:59 +0100 Subject: [PATCH] tag_client: Add explicit lua_State argument tag_client() said that it refers to the tag ontop of the lua stack. However, it implicitly used globalconf.L as its stack. So if you tagged a client with a tag from a coroutine, thinks would Go Wrong (tm). Fix this by adding an explicit lua_State* argument. Signed-off-by: Uli Schlachter --- objects/client.c | 2 +- objects/tag.c | 11 ++++++----- objects/tag.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/objects/client.c b/objects/client.c index 54b52873d..b8d3c4153 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1384,7 +1384,7 @@ luaA_client_tags(lua_State *L) } lua_pushnil(L); while(lua_next(L, 2)) - tag_client(c); + tag_client(L, c); lua_pop(L, 1); } diff --git a/objects/tag.c b/objects/tag.c index 4d7f3cb06..80bc00461 100644 --- a/objects/tag.c +++ b/objects/tag.c @@ -95,17 +95,18 @@ tag_client_emit_signal(lua_State *L, tag_t *t, client_t *c, const char *signame) } /** Tag a client with the tag on top of the stack. + * \param L The Lua VM state. * \param c the client to tag */ void -tag_client(client_t *c) +tag_client(lua_State *L, client_t *c) { - tag_t *t = luaA_object_ref_class(globalconf.L, -1, &tag_class); + tag_t *t = luaA_object_ref_class(L, -1, &tag_class); /* don't tag twice */ if(is_client_tagged(c, t)) { - luaA_object_unref(globalconf.L, t); + luaA_object_unref(L, t); return; } @@ -113,7 +114,7 @@ tag_client(client_t *c) ewmh_client_update_desktop(c); banning_need_update(); - tag_client_emit_signal(globalconf.L, t, c, "tagged"); + tag_client_emit_signal(L, t, c, "tagged"); } /** Untag a client with specified tag. @@ -218,7 +219,7 @@ luaA_tag_clients(lua_State *L) client_t *c = luaA_checkudata(L, -1, &client_class); /* push tag on top of the stack */ lua_pushvalue(L, 1); - tag_client(c); + tag_client(L, c); lua_pop(L, 1); } } diff --git a/objects/tag.h b/objects/tag.h index b9d43193c..c2aa2370d 100644 --- a/objects/tag.h +++ b/objects/tag.h @@ -25,7 +25,7 @@ #include "client.h" int tags_get_first_selected_index(void); -void tag_client(client_t *); +void tag_client(lua_State *, client_t *); void untag_client(client_t *, tag_t *); bool is_client_tagged(client_t *, tag_t *); void tag_unref_simplified(tag_t **);