luaapi: Fix assertion error on invalid callback

previousl this would assert in luaW_callwidgetcallback
This commit is contained in:
gfgtdf 2023-12-11 23:30:53 +01:00
parent 81145470c3
commit 9f51db3e47

View file

@ -285,6 +285,9 @@ static int intf_set_dialog_callback(lua_State* L)
if(!wd) {
throw std::invalid_argument("the widget has no window assigned");
}
if(!lua_isfunction(L, 2)) {
return luaL_argerror(L, 2, "callback must be a function");
}
lua_pushvalue(L, 2);
bool already_exists = luaW_setwidgetcallback(L, w, wd, "callback");