Merge pull request #108883 from aaronfranke/editor-crash-scene-tree-dock

Fix crash in SceneTreeDock when closing a scene with a selected node
This commit is contained in:
Thaddeus Crews 2025-07-23 13:27:08 -05:00
commit 2bfc3212ad
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
3 changed files with 10 additions and 4 deletions

View file

@ -2930,12 +2930,9 @@ void SceneTreeDock::_selection_changed() {
}
// Untrack script changes in previously selected nodes.
for (Node *node : node_previous_selection) {
node->disconnect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
}
clear_previous_node_selection();
// Track script changes in newly selected nodes.
node_previous_selection.clear();
node_previous_selection.reserve(editor_selection->get_selection().size());
for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) {
Node *node = E.key;
@ -3378,6 +3375,13 @@ static bool _is_same_selection(const Vector<Node *> &p_first, const List<Node *>
return true;
}
void SceneTreeDock::clear_previous_node_selection() {
for (Node *node : node_previous_selection) {
node->disconnect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
}
node_previous_selection.clear();
}
void SceneTreeDock::set_selection(const Vector<Node *> &p_nodes) {
// If the nodes selected are the same independently of order then return early.
if (_is_same_selection(p_nodes, editor_selection->get_full_selected_node_list())) {