Merge pull request #96236 from kleonc/scene_tree_dock_fix_trying_to_remove_internal_node

Fix `SceneTreeDock` invalid state after trying to remove internal Node
This commit is contained in:
Rémi Verschelde 2024-08-30 11:43:09 +02:00
commit ed8baa378a
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 7 additions and 4 deletions

View File

@ -2650,6 +2650,13 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
}
}
if (!entire_scene) {
for (const Node *E : remove_list) {
// `move_child` + `get_index` doesn't really work for internal nodes.
ERR_FAIL_COND_MSG(E->get_internal_mode() != INTERNAL_MODE_DISABLED, "Trying to remove internal node, this is not supported.");
}
}
EditorNode::get_singleton()->hide_unused_editors(this);
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
@ -2662,10 +2669,6 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
undo_redo->add_undo_method(scene_tree, "update_tree");
undo_redo->add_undo_reference(edited_scene);
} else {
for (const Node *E : remove_list) {
// `move_child` + `get_index` doesn't really work for internal nodes.
ERR_FAIL_COND_MSG(E->get_internal_mode() != INTERNAL_MODE_DISABLED, "Trying to remove internal node, this is not supported.");
}
if (delete_tracks_checkbox->is_pressed() || p_cut) {
remove_list.sort_custom<Node::Comparator>(); // Sort nodes to keep positions.
HashMap<Node *, NodePath> path_renames;