mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 14:42:44 +00:00
[lua] Add traceback info when a doc object is deleted and we try to use it
A reference to a doc object (Sprite, Layer, Cel, etc.) is done through its ID in the scripting engine, when we try to access it from a script that element might be already deleted. Previously we displayed the a message like "Using a nil 'Cel' object". With this change we show the traceback and a "Tried to access a deleted 'Cel'" message.
This commit is contained in:
parent
741cd31fdd
commit
558ff54cb0
@ -41,7 +41,11 @@ template <typename T> T* check_docobj(lua_State* L, T* obj) {
|
||||
if (obj)
|
||||
return obj;
|
||||
else {
|
||||
luaL_error(L, "Using a nil '%s' object", get_mtname<T>());
|
||||
luaL_traceback(L, L, nullptr, 1);
|
||||
const char* traceback = lua_tostring(L, -1);
|
||||
luaL_error(L, "%s: Tried to access a deleted '%s'",
|
||||
traceback ? traceback: "",
|
||||
get_mtname<T>());
|
||||
ASSERT(false); // unreachable code
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user