Skip to content

Commit e82a446

Browse files
committed
Fixed 'Change Type' ignoring non-top-level nodes and editing foreign nodes/ being available when it is not.
1 parent c96e119 commit e82a446

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

editor/docks/scene_tree_dock.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

24042406
bool 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

24332438
bool 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()) {

editor/docks/scene_tree_dock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,12 @@ class SceneTreeDock : public EditorDock {
252252
void _new_scene_from(const String &p_file);
253253
void _set_node_owner_recursive(Node *p_node, Node *p_owner, const HashMap<const Node *, Node *> &p_inverse_duplimap);
254254

255+
//[[deprecated("Use _validate_no_foreign_selected() instead (see PR #119617).")]]
255256
bool _validate_no_foreign();
257+
bool _validate_no_foreign_selected(const List<Node *> &p_selected);
258+
//[[deprecated("Use _validate_no_instance_selected() instead (see PR #119617).")]]
256259
bool _validate_no_instance();
260+
bool _validate_no_instance_selected(const List<Node *> &p_selected);
257261
void _selection_changed();
258262
void _update_script_button();
259263
void _queue_update_script_button();

0 commit comments

Comments
 (0)