Fix replace parent node and paste child nodes then move cause crash #113484
+1
−0
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.
Issue Descripion
As described in #113453, if we first change parent node type, then paste child nodes, then move nodes in editor. We will attempt to move the invalid nodes from before the changes.
Solution
We can setpending_click_select = nullptrinpaste_nodes()to prevent using invalid node.Edited: We should clean
tree_clicked = falseafterreplace_node(), then later mouse click event won't select node by mistake.replace-paste-move-crash.webm
Explaination
When we execute "change type", we click mouse right key to display context menu, which will trigger
input()to marktree_clicked = trueand savepending_click_select = current_node.godot/editor/docks/scene_tree_dock.cpp
Lines 148 to 152 in 9f5309a
But after executing
replace_node(),tree_clickedis stilltrue. That makes when triggered_handle_select, thepending_click_selectalways updated.godot/editor/docks/scene_tree_dock.cpp
Lines 1871 to 1877 in 9f5309a
Whenever we click mouse to trigger next
input(), thepending_click_selectwill update toeditor_selectionwithpush_item. That makes the current selection changed and causes crash.godot/editor/docks/scene_tree_dock.cpp
Lines 154 to 157 in 9f5309a