Missing a function in love to check object:isReleased() or something like that
Posted: Wed Apr 14, 2021 9:03 am
Hi,
I'm creating and remove various objects on the fly and sometimes i'm in a situation that a draw loop is using an object that don't exist anymore.
I can fix this by refactoring some code, but maybe I can check if a object has been released (but don't know how).
Basic example code:
Thanks,
GCMartijn
I'm creating and remove various objects on the fly and sometimes i'm in a situation that a draw loop is using an object that don't exist anymore.
I can fix this by refactoring some code, but maybe I can check if a object has been released (but don't know how).
Basic example code:
Code: Select all
local function drawCanvas1()
love.graphics.clear()
love.graphics.setColor(1, 0, 0)
love.graphics.rectangle("fill", 0, 0, 100, 100)
end
function love.load()
canvas1 = love.graphics.newCanvas()
-- release it for this example
canvas1:release()
print(canvas1) -- Canvas: NULL -- why not nil ?
print(canvas1.Canvas) -- nil ^ above looks like a table, but I don't get the NULL
print(canvas1:type()) -- Canvas ! , its still a Canvas
if canvas1 == nil then -- I want to check if a resource is released
return
end
-- now it will give a error here
canvas1:renderTo(drawCanvas1)
end
GCMartijn