Added Object:release. Calling it is the equivalent of removing all Lua-side references to an object and doing a full garbage collection cycle (thus deleting the object from memory if nothing else in LÖVE's code is referencing it).

Any attempt to call a method on the object after it has been released will result in an error. Object:release() returns true if it was successful, or false if not (if it has already been released previously).

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-10-06 21:59:01 -03:00
parent bfb00239fd
commit 37520bd18b
7 changed files with 69 additions and 9 deletions
+6
View File
@@ -161,6 +161,7 @@ local _getWidth = ImageData.getWidth
local _getHeight = ImageData.getHeight
local _getDimensions = ImageData.getDimensions
local _getFormat = ImageData.getFormat
local _release = ImageData.release
-- Table which holds ImageData objects as keys, and information about the objects
-- as values. Uses weak keys so the ImageData objects can still be GC'd properly.
@@ -270,5 +271,10 @@ function ImageData:getFormat()
return objectcache[self].format
end
function ImageData:release()
objectcache[self] = nil
return _release(self)
end
-- DO NOT REMOVE THE NEXT LINE. It is used to load this file as a C++ string.
--)luastring"--"