Skip to content

Commit 7cc3f37

Browse files
authored
Merge pull request #109801 from KoBeWi/a_classic_fix
Track last selection using ObjectID
2 parents be04069 + 27fb218 commit 7cc3f37

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

editor/docks/scene_tree_dock.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,7 +2936,7 @@ void SceneTreeDock::_selection_changed() {
29362936
node_previous_selection.reserve(editor_selection->get_selection().size());
29372937
for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) {
29382938
Node *node = E.key;
2939-
node_previous_selection.push_back(node);
2939+
node_previous_selection.push_back(node->get_instance_id());
29402940
node->connect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
29412941
}
29422942
_queue_update_script_button();
@@ -3376,8 +3376,11 @@ static bool _is_same_selection(const Vector<Node *> &p_first, const List<Node *>
33763376
}
33773377

33783378
void SceneTreeDock::clear_previous_node_selection() {
3379-
for (Node *node : node_previous_selection) {
3380-
node->disconnect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
3379+
for (const ObjectID &id : node_previous_selection) {
3380+
Node *node = ObjectDB::get_instance<Node>(id);
3381+
if (node) {
3382+
node->disconnect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
3383+
}
33813384
}
33823385
node_previous_selection.clear();
33833386
}

editor/docks/scene_tree_dock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class SceneTreeDock : public VBoxContainer {
135135

136136
EditorData *editor_data = nullptr;
137137
EditorSelection *editor_selection = nullptr;
138-
LocalVector<Node *> node_previous_selection;
138+
LocalVector<ObjectID> node_previous_selection;
139139
bool update_script_button_queued = false;
140140

141141
List<Node *> node_clipboard;

0 commit comments

Comments
 (0)