@@ -800,11 +800,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
800800 break ;
801801 }
802802
803- if (!_validate_no_foreign ()) {
803+ List<Node *> full_selection = editor_selection->get_full_selected_node_list ();
804+
805+ if (!_validate_no_foreign_selected (full_selection)) {
804806 break ;
805807 }
806808
807- if (!_validate_no_instance ( )) {
809+ if (!_validate_no_instance_selected (full_selection )) {
808810 break ;
809811 }
810812
@@ -2402,9 +2404,12 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
24022404}
24032405
24042406bool SceneTreeDock::_validate_no_foreign () {
2405- const List<Node *> selection = editor_selection->get_top_selected_node_list ();
2407+ // Deprecated (see PR #119617).
2408+ return _validate_no_foreign_selected (editor_selection->get_top_selected_node_list ());
2409+ }
24062410
2407- for (Node *E : selection) {
2411+ bool SceneTreeDock::_validate_no_foreign_selected (const List<Node *> &p_selected) {
2412+ for (Node *E : p_selected) {
24082413 if (E != edited_scene && E->get_owner () != edited_scene) {
24092414 accept->set_text (TTR (" Can't operate on nodes from a foreign scene!" ));
24102415 accept->popup_centered ();
@@ -2431,9 +2436,12 @@ bool SceneTreeDock::_validate_no_foreign() {
24312436}
24322437
24332438bool SceneTreeDock::_validate_no_instance () {
2434- const List<Node *> selection = editor_selection->get_top_selected_node_list ();
2439+ // Deprecated (see PR #119617).
2440+ return _validate_no_instance_selected (editor_selection->get_top_selected_node_list ());
2441+ }
24352442
2436- for (Node *E : selection) {
2443+ bool SceneTreeDock::_validate_no_instance_selected (const List<Node *> &p_selected) {
2444+ for (Node *E : p_selected) {
24372445 if (E != edited_scene && E->is_instance ()) {
24382446 accept->set_text (TTR (" This operation can't be done on instantiated scenes." ));
24392447 accept->popup_centered ();
@@ -3127,7 +3135,8 @@ void SceneTreeDock::_create() {
31273135 _do_create (parent);
31283136
31293137 } else if (current_option == TOOL_CHANGE_TYPE) {
3130- const List<Node *> selection = editor_selection->get_top_selected_node_list ();
3138+ // TODO: Rename selection to full_selection?
3139+ const List<Node *> selection = editor_selection->get_full_selected_node_list ();
31313140 ERR_FAIL_COND (selection.is_empty ());
31323141
31333142 EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton ();
@@ -3860,8 +3869,13 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
38603869 ERR_FAIL_COND (!EditorNode::get_singleton ()->get_edited_scene ());
38613870 menu->clear (false );
38623871
3872+ // TODO: Rename selection to top_selection?
3873+ // Returns only the top-level selected nodes (i.e. excludes any selected node whose parent is also selected).
3874+ // The first node selected by the user is at the front of the list (i.e. not sorted in scene tree order).
38633875 const List<Node *> selection = editor_selection->get_top_selected_node_list ();
3864- List<Node *> full_selection = editor_selection->get_full_selected_node_list (); // Above method only returns nodes with common parent.
3876+ // Returns all selected nodes (list version of "get_selected_nodes").
3877+ // The first node selected by the user is at the front of the list (i.e. not sorted in scene tree order).
3878+ List<Node *> full_selection = editor_selection->get_full_selected_node_list ();
38653879
38663880 scene_tree->get_scene_tree ()->grab_focus (true );
38673881
@@ -3938,7 +3952,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
39383952 bool can_replace = true ;
39393953
39403954 if (profile_allow_editing) {
3941- for (Node *E : selection ) {
3955+ for (Node *E : full_selection ) {
39423956 if (E != edited_scene && (E->get_owner () != edited_scene || E->is_instance ())) {
39433957 can_replace = false ;
39443958 if (!E->is_instance ()) {
0 commit comments