Browse Source

Fix Can't reopen signals panel immediately after connecting a signal #92996

Hilderin 1 year ago
parent
commit
64ba2cf3a9

+ 0 - 2
editor/connections_dialog.cpp

@@ -981,7 +981,6 @@ void ConnectionsDock::_make_or_edit_connection() {
 		}
 
 		EditorNode::get_singleton()->emit_signal(SNAME("script_add_function_request"), target, cd.method, script_function_args);
-		hide();
 	}
 
 	update_tree();
@@ -1607,7 +1606,6 @@ ConnectionsDock::ConnectionsDock() {
 	connect_button->connect(SceneStringName(pressed), callable_mp(this, &ConnectionsDock::_connect_pressed));
 
 	connect_dialog = memnew(ConnectDialog);
-	connect_dialog->connect("connected", callable_mp(NodeDock::get_singleton(), &NodeDock::restore_last_valid_node), CONNECT_DEFERRED);
 	connect_dialog->set_process_shortcut_input(true);
 	add_child(connect_dialog);
 

+ 6 - 0
editor/editor_node.cpp

@@ -2304,6 +2304,12 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in
 	_edit_current();
 }
 
+void EditorNode::edit_previous_item() {
+	if (editor_history.previous()) {
+		_edit_current();
+	}
+}
+
 void EditorNode::push_item_no_inspector(Object *p_object) {
 	_add_to_history(p_object, "", false);
 	_edit_current(false, true);

+ 1 - 0
editor/editor_node.h

@@ -764,6 +764,7 @@ public:
 
 	void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false);
 	void push_item_no_inspector(Object *p_object);
+	void edit_previous_item();
 	void edit_item(Object *p_object, Object *p_editing_owner);
 	void push_node_item(Node *p_node);
 	void hide_unused_editors(const Object *p_editing_owner = nullptr);

+ 0 - 16
editor/node_dock.cpp

@@ -67,23 +67,11 @@ void NodeDock::update_lists() {
 	connections->update_tree();
 }
 
-void NodeDock::_on_node_tree_exited() {
-	set_node(nullptr);
-}
-
 void NodeDock::set_node(Node *p_node) {
-	if (last_valid_node) {
-		last_valid_node->disconnect(SceneStringName(tree_exited), callable_mp(this, &NodeDock::_on_node_tree_exited));
-		last_valid_node = nullptr;
-	}
-
 	connections->set_node(p_node);
 	groups->set_current(p_node);
 
 	if (p_node) {
-		last_valid_node = p_node;
-		last_valid_node->connect(SceneStringName(tree_exited), callable_mp(this, &NodeDock::_on_node_tree_exited));
-
 		if (connections_button->is_pressed()) {
 			connections->show();
 		} else {
@@ -100,10 +88,6 @@ void NodeDock::set_node(Node *p_node) {
 	}
 }
 
-void NodeDock::restore_last_valid_node() {
-	set_node(last_valid_node);
-}
-
 NodeDock::NodeDock() {
 	singleton = this;
 

+ 0 - 3
editor/node_dock.h

@@ -47,7 +47,6 @@ class NodeDock : public VBoxContainer {
 	HBoxContainer *mode_hb = nullptr;
 
 	Label *select_a_node = nullptr;
-	Node *last_valid_node = nullptr;
 
 private:
 	static NodeDock *singleton;
@@ -58,11 +57,9 @@ public:
 protected:
 	static void _bind_methods();
 	void _notification(int p_what);
-	void _on_node_tree_exited();
 
 public:
 	void set_node(Node *p_node);
-	void restore_last_valid_node();
 
 	void show_groups();
 	void show_connections();

+ 4 - 0
editor/plugins/script_editor_plugin.cpp

@@ -2856,6 +2856,10 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
 
 		break;
 	}
+
+	// Move back to the previously edited node to reselect it in the Inspector and the NodeDock.
+	// We assume that the previous item is the node on which the callbacks were added.
+	EditorNode::get_singleton()->edit_previous_item();
 }
 
 void ScriptEditor::_save_editor_state(ScriptEditorBase *p_editor) {

+ 1 - 0
editor/scene_tree_dock.cpp

@@ -2696,6 +2696,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
 	editor_history->cleanup_history();
 	InspectorDock::get_singleton()->call("_prepare_history");
 	InspectorDock::get_singleton()->update(nullptr);
+	NodeDock::get_singleton()->set_node(nullptr);
 }
 
 void SceneTreeDock::_update_script_button() {