From 64ba2cf3a92090f6474b7c752974f5f8ac45561b Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:51:51 -0400 Subject: [PATCH] Fix Can't reopen signals panel immediately after connecting a signal #92996 --- editor/connections_dialog.cpp | 2 -- editor/editor_node.cpp | 6 ++++++ editor/editor_node.h | 1 + editor/node_dock.cpp | 16 ---------------- editor/node_dock.h | 3 --- editor/plugins/script_editor_plugin.cpp | 4 ++++ editor/scene_tree_dock.cpp | 1 + 7 files changed, 12 insertions(+), 21 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index cede2c0ab66..e68c1829333 100644 --- a/editor/connections_dialog.cpp +++ b/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); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d5e12424065..5d3143d6640 100644 --- a/editor/editor_node.cpp +++ b/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); diff --git a/editor/editor_node.h b/editor/editor_node.h index 899da994501..c01e0d2a8fd 100644 --- a/editor/editor_node.h +++ b/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); diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index b8e0b61cd9e..0c79e5d747c 100644 --- a/editor/node_dock.cpp +++ b/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; diff --git a/editor/node_dock.h b/editor/node_dock.h index 41495ffeadd..e9dcc41d48c 100644 --- a/editor/node_dock.h +++ b/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(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 334b253316a..f96ec95234a 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/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) { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 11e477e0443..fe8996f7a0f 100644 --- a/editor/scene_tree_dock.cpp +++ b/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() {