mirror of
https://github.com/love2d/love.git
synced 2026-08-14 10:13:46 +02:00
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:
@@ -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"--"
|
||||
|
||||
Reference in New Issue
Block a user