Forráskód Böngészése

Track last selection using ObjectID

kobewi 2 hete
szülő
commit
27fb2181cd
2 módosított fájl, 7 hozzáadás és 4 törlés
  1. 6 3
      editor/docks/scene_tree_dock.cpp
  2. 1 1
      editor/docks/scene_tree_dock.h

+ 6 - 3
editor/docks/scene_tree_dock.cpp

@@ -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();
 }

+ 1 - 1
editor/docks/scene_tree_dock.h

@@ -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;