summaryrefslogtreecommitdiff
path: root/library/LuaApi.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-08-22 18:18:19 +0400
committerAlexander Gavrilov2012-08-22 18:18:19 +0400
commit7987ea9a9877a4e9f44492210784c7e8d7f94bb9 (patch)
tree768bd5aacaba64be23592b0a93f99ec8dd733b3d /library/LuaApi.cpp
parent6e8b68fb29c52f1782938bf7aa564a516079bf61 (diff)
downloaddfhack-7987ea9a9877a4e9f44492210784c7e8d7f94bb9.tar.gz
dfhack-7987ea9a9877a4e9f44492210784c7e8d7f94bb9.tar.bz2
dfhack-7987ea9a9877a4e9f44492210784c7e8d7f94bb9.tar.xz
Put some compatibility features into the base dfhack viewscreen.
Diffstat (limited to 'library/LuaApi.cpp')
-rw-r--r--library/LuaApi.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index 7f18ce3e..d25da808 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -1179,7 +1179,14 @@ int screen_show(lua_State *L)
before = Lua::CheckDFObject<df::viewscreen>(L, 2);
df::viewscreen *screen = dfhack_lua_viewscreen::get_pointer(L, 1, true);
- lua_pushboolean(L, Screen::show(screen, before));
+
+ bool ok = Screen::show(screen, before);
+
+ // If it is a table, get_pointer created a new object. Don't leak it.
+ if (!ok && lua_istable(L, 1))
+ delete screen;
+
+ lua_pushboolean(L, ok);
return 1;
}