New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nodes deleted in a scene unexpectedly remain when referencing them with a tool script. #22105
Comments
Wild guess: nodes are kept in memory for the undo operation. Since the variable contains a direct pointer, it can still be accessed. |
@vnen That makes sense, but I must say it does make things quite difficulty in tool code for detecting when nodes have been deleted out of the scene tree. Would you have any suggestions for code like this? What can I use in place of
Presently, there is a lot of odds side stuff I have to do to be able to try and catch this, and sometimes there are really odd timing issues when processing loops are needed. Right now for me it is leading towards dozens of lines of copy and paste code per tool script, that is potentially buggy and unreliable when mixed with signals/yields/defers/processing. |
There is |
Bailing me out yet again tonight. XD Whew, glad there was something. I gave up checking properties and methods too soon on it, it is at least out of the tree. A small thing, but will make life easier going forward. Going to try to update the title here of this thread to be more precise. |
The issue is still reproducible in 3.3, the error message changed a bit:
I'm not sure if anything can be done about it though. |
EDIT / UPDATE
As mentioned below, this is most certainly for undo purposes, and
is_inside_treeO
is at least a method of detecting this, if used carefully. There are situations where you might pluck stuff out of the tree temporarily for your own reasons, so it might be lead to some collisions.Maybe there is some way to make it more intuitive by default, better error messages, or a very specific editor script method.
...
Original
Alpha v3.1 4547e22
Example Project: Tool Deleted Nodes Leak.zip
When deleting a node in the editor, tool scripts that have a reference to a node in the scene tree retain that object. Not only that, it is completely accessible.
This is very tricky to work around when making tools that need to know when objects are deleted.
The $ and get_node will not find them.
This is what happens when it is deleted. Left is the variable and the right is the get_node() result.
The text was updated successfully, but these errors were encountered: