mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 13:21:34 +00:00
lua: Fix may_get_docobj() when the object is not of the expected type
This commit is contained in:
parent
44205c8121
commit
3211bc67b1
@ -28,12 +28,13 @@ template <typename T> void push_docobj(lua_State* L, T* obj) {
|
||||
}
|
||||
|
||||
template <typename T> T* may_get_docobj(lua_State* L, int index) {
|
||||
const doc::ObjectId id = *(doc::ObjectId*)luaL_checkudata(L, index, get_mtname<T>());
|
||||
T* obj = doc::get<T>(id);
|
||||
if (obj)
|
||||
return obj;
|
||||
else
|
||||
return nullptr;
|
||||
const doc::ObjectId* id = (doc::ObjectId*)luaL_testudata(L, index, get_mtname<T>());
|
||||
if (id) {
|
||||
T* obj = doc::get<T>(*id);
|
||||
if (obj)
|
||||
return obj;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename T> T* check_docobj(lua_State* L, T* obj) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user