[Editor] Prevent deferred tooltip update crash #102659
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Caused by
TreeItem
s being accessed after clearing the tree on reset.Can largely confirm this at least on 4.3, though without debug symbols I'm not sure if it is the same issue, can't reliably on 4.2, but hard to tell exactly why. I can reliably trigger it on debug builds, and with a few scenes in 4.4.beta3
Considered using
ObjectID
but I think this is a case where things should be solved by catching the problem at the source. This might still occur in edge cases where the timer fires during other updates, but this at least solves the issue reliably for me.To trigger this bug:
The editor should crash, caused by various errors of memory access related to
TreeItem
nodes, this would be because the deferred tooltip update holding a reference to a now freedTreeItem
, relevant code is:godot/editor/gui/scene_tree_editor.cpp
Lines 642 to 650 in 261e7d3
Where the timer set up, and:
godot/editor/gui/scene_tree_editor.cpp
Lines 657 to 667 in 261e7d3
Where the crash is triggered, due to accessing internal data of a freed node
Ability to trigger this might vary based on hardware and general performance as this is a timing issue