Fix exception when passing nil to some functions in interface api, fixes #849

This commit is contained in:
jacob1 2022-07-20 21:51:56 -04:00
parent c603c41b92
commit a0016a2b9c
No known key found for this signature in database
GPG Key ID: 4E58A32D510E1995
5 changed files with 5 additions and 6 deletions

View File

@ -62,8 +62,7 @@ int LuaButton::text(lua_State * l)
int args = lua_gettop(l); int args = lua_gettop(l);
if(args) if(args)
{ {
luaL_checktype(l, 1, LUA_TSTRING); button->SetText(ByteString(luaL_checkstring(l, 1)).FromUtf8());
button->SetText(ByteString(lua_tostring(l, 1)).FromUtf8());
return 0; return 0;
} }
else else

View File

@ -60,7 +60,7 @@ int LuaCheckbox::text(lua_State * l)
int args = lua_gettop(l); int args = lua_gettop(l);
if(args) if(args)
{ {
checkbox->SetText(ByteString(lua_tostring(l, 1)).FromUtf8()); checkbox->SetText(ByteString(luaL_checkstring(l, 1)).FromUtf8());
return 0; return 0;
} }
else else

View File

@ -37,7 +37,7 @@ int LuaLabel::text(lua_State * l)
int args = lua_gettop(l); int args = lua_gettop(l);
if(args) if(args)
{ {
label->SetText(ByteString(lua_tostring(l, 1)).FromUtf8()); label->SetText(ByteString(luaL_checkstring(l, 1)).FromUtf8());
return 0; return 0;
} }
else else

View File

@ -53,7 +53,7 @@ int LuaProgressBar::status(lua_State * l)
int args = lua_gettop(l); int args = lua_gettop(l);
if(args) if(args)
{ {
progressBar->SetStatus(ByteString(lua_tostring(l, 1)).FromUtf8()); progressBar->SetStatus(ByteString(luaL_checkstring(l, 1)).FromUtf8());
return 0; return 0;
} }
else else

View File

@ -77,7 +77,7 @@ int LuaTextbox::text(lua_State * l)
int args = lua_gettop(l); int args = lua_gettop(l);
if(args) if(args)
{ {
textbox->SetText(ByteString(lua_tostring(l, 1)).FromUtf8()); textbox->SetText(ByteString(luaL_checkstring(l, 1)).FromUtf8());
return 0; return 0;
} }
else else