From db49c1f0e4be189ef4ce35a62a6e4a1cd48a8a0a Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Sun, 4 Aug 2024 16:20:05 +0800 Subject: [PATCH] fix(obj): add logic to process nil parent Signed-off-by: Neo Xu --- src/obj.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/obj.c b/src/obj.c index 63ef3d0..ec2a29e 100644 --- a/src/obj.c +++ b/src/obj.c @@ -1053,8 +1053,11 @@ LUALIB_API int luavgl_obj_create_helper(lua_State *L, lv_obj_t *parent; int type = lua_type(L, 1); - if (type == LUA_TTABLE || type == LUA_TNONE || type == LUA_TNIL) { + if (type == LUA_TTABLE) { parent = ctx->root; + } else if (type == LUA_TNONE || type == LUA_TNIL) { + parent = ctx->root; + lua_remove(L, 1); /* Remove nil from stack */ } else { parent = luavgl_to_obj(L, 1); lua_remove(L, 1); /* Remove parent from stack */