Merge pull request #90536 from Rindbee/make-the-inherited-scene-root-node-unable-to-change-type

Make the inherited scene root node unable to change type
This commit is contained in:
Rémi Verschelde 2024-04-13 11:30:25 +02:00
commit c88993411d
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 19 additions and 10 deletions

View File

@ -2079,17 +2079,19 @@ bool SceneTreeDock::_validate_no_foreign() {
return false; return false;
} }
// When edited_scene inherits from another one the root Node will be the parent Scene, if (edited_scene->get_scene_inherited_state().is_valid()) {
// we don't want to consider that Node a foreign one otherwise we would not be able to // When edited_scene inherits from another one the root Node will be the parent Scene,
// delete it. // we don't want to consider that Node a foreign one otherwise we would not be able to
if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E) { // delete it.
continue; if (edited_scene == E && current_option != TOOL_REPLACE) {
} continue;
}
if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { if (edited_scene == E || edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) {
accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); accept->set_text(TTR("Can't operate on nodes the current scene inherits from!"));
accept->popup_centered(); accept->popup_centered();
return false; return false;
}
} }
} }
@ -3443,6 +3445,13 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
can_replace = false; can_replace = false;
break; break;
} }
if (edited_scene->get_scene_inherited_state().is_valid()) {
if (E == edited_scene || edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) {
can_replace = false;
break;
}
}
} }
if (can_replace) { if (can_replace) {