Merge pull request #109801 from KoBeWi/a_classic_fix

Track last selection using ObjectID
This commit is contained in:
Thaddeus Crews
2025-08-20 16:18:02 -05:00
committed by GitHub
2 changed files with 7 additions and 4 deletions

View File

@@ -2936,7 +2936,7 @@ void SceneTreeDock::_selection_changed() {
node_previous_selection.reserve(editor_selection->get_selection().size());
for (const KeyValue<Node *, Object *> &E : editor_selection->get_selection()) {
Node *node = E.key;
node_previous_selection.push_back(node);
node_previous_selection.push_back(node->get_instance_id());
node->connect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
}
_queue_update_script_button();
@@ -3376,8 +3376,11 @@ static bool _is_same_selection(const Vector<Node *> &p_first, const List<Node *>
}
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));
for (const ObjectID &id : node_previous_selection) {
Node *node = ObjectDB::get_instance<Node>(id);
if (node) {
node->disconnect(CoreStringName(script_changed), callable_mp(this, &SceneTreeDock::_queue_update_script_button));
}
}
node_previous_selection.clear();
}

View File

@@ -135,7 +135,7 @@ class SceneTreeDock : public VBoxContainer {
EditorData *editor_data = nullptr;
EditorSelection *editor_selection = nullptr;
LocalVector<Node *> node_previous_selection;
LocalVector<ObjectID> node_previous_selection;
bool update_script_button_queued = false;
List<Node *> node_clipboard;