mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Fix crash in SceneTreeDock when closing a scene with a selected node
This commit is contained in:
@@ -2925,12 +2925,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;
|
||||
@@ -3373,6 +3370,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())) {
|
||||
|
||||
@@ -324,6 +324,7 @@ public:
|
||||
void set_edited_scene(Node *p_scene);
|
||||
void instantiate(const String &p_file);
|
||||
void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr);
|
||||
void clear_previous_node_selection();
|
||||
void set_selection(const Vector<Node *> &p_nodes);
|
||||
void set_selected(Node *p_node, bool p_emit_selected = false);
|
||||
void fill_path_renames(Node *p_node, Node *p_new_parent, HashMap<Node *, NodePath> *p_renames);
|
||||
|
||||
@@ -4248,6 +4248,7 @@ void EditorNode::_set_current_scene_nocheck(int p_idx) {
|
||||
Node *old_scene = get_editor_data().get_edited_scene_root();
|
||||
|
||||
editor_selection->clear();
|
||||
SceneTreeDock::get_singleton()->clear_previous_node_selection();
|
||||
editor_data.set_edited_scene(p_idx);
|
||||
|
||||
Node *new_scene = editor_data.get_edited_scene_root();
|
||||
|
||||
Reference in New Issue
Block a user