mirror of
https://github.com/love2d/love.git
synced 2026-08-12 16:40:57 +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:
@@ -46,6 +46,7 @@ local _getSampleCount = SoundData.getSampleCount
|
||||
local _getSampleRate = SoundData.getSampleRate
|
||||
local _getChannels = SoundData.getChannels
|
||||
local _getDuration = SoundData.getDuration
|
||||
local _release = SoundData.release
|
||||
|
||||
-- Table which holds SoundData objects as keys, and information about the objects
|
||||
-- as values. Uses weak keys so the SoundData objects can still be GC'd properly.
|
||||
@@ -133,5 +134,10 @@ function SoundData:getDuration()
|
||||
return objectcache[self].duration
|
||||
end
|
||||
|
||||
function SoundData: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