Changed luax_pushtype to retain the pushed object itself, but only if the object isn't in the Lua state already.

Previously, calling e.g. love.graphics.getFont() 10,000 times would retain the object 10,000 times (and release it 10,000 times when the Font object was garbage-collected in the Lua state.) Now it will only retain it once and release it once.
This commit is contained in:
Alex Szpakowski
2014-08-09 16:04:59 -03:00
parent 191b910f23
commit da7cd267ea
30 changed files with 113 additions and 118 deletions
-3
View File
@@ -288,10 +288,7 @@ int w_getIcon(lua_State *L)
{
image::ImageData *i = instance()->getIcon();
if (i)
{
i->retain();
luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, i);
}
else
lua_pushnil(L);
return 1;