Skip to content

Commit

Permalink
Merge pull request #93110 from Hilderin/fix-signal-panel-after-connec…
Browse files Browse the repository at this point in the history
…tion

Fix Can't reopen signals panel immediately after connecting a signal
  • Loading branch information
akien-mga committed Jun 19, 2024
2 parents 4e01d86 + 64ba2cf commit a50b535
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 21 deletions.
2 changes: 0 additions & 2 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,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);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ class EditorNode : public Node {

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);
Expand Down
16 changes: 0 additions & 16 deletions editor/node_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions editor/node_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -58,11 +57,9 @@ class NodeDock : public VBoxContainer {
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();
Expand Down
4 changes: 4 additions & 0 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a50b535

Please sign in to comment.