Skip to content

Commit

Permalink
fix(obj): add logic to process nil parent
Browse files Browse the repository at this point in the history
Signed-off-by: Neo Xu <[email protected]>
  • Loading branch information
XuNeo committed Aug 4, 2024
1 parent 07a417c commit db49c1f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit db49c1f

Please sign in to comment.