degesch: Lua: fix luaL_ref() usage
This commit is contained in:
parent
aca153f575
commit
64143a5957
21
degesch.c
21
degesch.c
@ -8018,12 +8018,13 @@ lua_plugin_add_config_schema (struct lua_plugin *plugin,
|
||||
schema->comment = xstrdup (lua_tostring (L, -1));
|
||||
if (lua_plugin_check_field (L, values, "default", LUA_TSTRING, true))
|
||||
schema->default_ = xstrdup (lua_tostring (L, -1));
|
||||
if (lua_plugin_check_field (L, values, "on_change", LUA_TFUNCTION, true))
|
||||
self->ref_on_change = luaL_ref (L, -1);
|
||||
if (lua_plugin_check_field (L, values, "validate", LUA_TFUNCTION, true))
|
||||
self->ref_validate = luaL_ref (L, -1);
|
||||
|
||||
lua_pop (L, 5);
|
||||
lua_pop (L, 3);
|
||||
|
||||
(void) lua_plugin_check_field (L, values, "on_change", LUA_TFUNCTION, true);
|
||||
self->ref_on_change = luaL_ref (L, LUA_REGISTRYINDEX);
|
||||
(void) lua_plugin_check_field (L, values, "validate", LUA_TFUNCTION, true);
|
||||
self->ref_validate = luaL_ref (L, LUA_REGISTRYINDEX);
|
||||
|
||||
// Try to install the created schema item into our configuration
|
||||
struct error *warning = NULL, *e = NULL;
|
||||
@ -8460,12 +8461,10 @@ lua_plugin_connect (lua_State *L)
|
||||
self->ref_on_success = LUA_REFNIL;
|
||||
self->ref_on_error = LUA_REFNIL;
|
||||
|
||||
if (lua_plugin_check_field (L, 3, "on_success", LUA_TFUNCTION, true))
|
||||
self->ref_on_success = luaL_ref (L, -1);
|
||||
if (lua_plugin_check_field (L, 3, "on_error", LUA_TFUNCTION, true))
|
||||
self->ref_on_error = luaL_ref (L, -1);
|
||||
|
||||
lua_pop (L, 2);
|
||||
(void) lua_plugin_check_field (L, 3, "on_success", LUA_TFUNCTION, true);
|
||||
self->ref_on_success = luaL_ref (L, LUA_REGISTRYINDEX);
|
||||
(void) lua_plugin_check_field (L, 3, "on_error", LUA_TFUNCTION, true);
|
||||
self->ref_on_error = luaL_ref (L, LUA_REGISTRYINDEX);
|
||||
|
||||
struct app_context *ctx = plugin->ctx;
|
||||
struct connector *connector = &self->connector;
|
||||
|
Loading…
Reference in New Issue
Block a user