Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash by ensuring selected node is a descendant of the edited scene #95420

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,21 +1064,23 @@ void Node3DEditorViewport::_select_region() {
if (found_nodes.has(sp)) {
continue;
}

found_nodes.insert(sp);

Node *node = Object::cast_to<Node>(sp);

// Selection requires that the node is the edited scene or its descendant, and has an owner.
if (node != edited_scene) {
if (!node->get_owner() || !edited_scene->is_ancestor_of(node)) {
continue;
}
node = edited_scene->get_deepest_editable_node(node);
}

// Prevent selection of nodes not owned by the edited scene.
while (node && node != edited_scene->get_parent()) {
Node *node_owner = node->get_owner();
if (node_owner == edited_scene || node == edited_scene || (node_owner != nullptr && edited_scene->is_editable_instance(node_owner))) {
break;
while (node != edited_scene) {
Node *node_owner = node->get_owner();
if (node_owner == edited_scene || (node_owner != nullptr && edited_scene->is_editable_instance(node_owner))) {
break;
}
node = node->get_parent();
}
node = node->get_parent();
}

// Replace the node by the group if grouped
Expand Down
Loading