Open IurieYSI opened 2 weeks ago
You can just use IsQueuedForDeletion
to get that status
It is queued to be freed from memory. "Unlike with Object.free, the node is not deleted instantly, and it can still be accessed before deletion. It is also safe to call queue_free multiple times. Use Object.is_queued_for_deletion to check if the node will be deleted at the end of the frame." - Godot Documentation
There's a lot of behind the scenes code that depends on the behavior of this, or rather on what is_instance_valid
checks, so to change this we would either have to make the bound function not work the same way or check for the queued status, or this would break a lot of internal code that is allowed to operate on the object until it is actually freed
That's exactly why queue_free
exists, it's there to not break internal things that might operate on it before the end of the frame, otherwise you'd just use free
Tested versions
tested on v4.3.stable.mono.official
System information
Windows 10 - Godot v4.3.stable.mono.official
Issue description
If we call
node.QueueFree()
,IsInstanceValid(node)
should returnfalse
even before the end of the frame. I can't think of a reason why would anyone need to haveIsInstanceValid(node)
returning true after anode.QueueFree()
call.Steps to reproduce
IsInstanceValid
IsInstanceValid
It prints out
and I think it must print out
Minimal reproduction project (MRP)