Skip to content

Fix the extra arguments of type NodePath in the connection dialog do not work #107013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,33 @@ class ConnectDialogBinds : public Object {
}
}

void update_base_node_relative(Node *p_node) {
Node *old_base = nullptr;
if (has_meta("__base_node_relative")) {
old_base = Object::cast_to<Node>(get_meta("__base_node_relative"));
}

if (old_base == p_node) {
return;
}
// The cdbinds is a proxy object, so we want the node path to be relative to the target node.
set_meta("__base_node_relative", p_node);

if (!old_base) {
return;
}

// Update existing outdated node paths.
for (int i = 0; i < params.size(); i++) {
if (params[i].get_type() != Variant::NODE_PATH) {
continue;
}
StringName property_name = "bind/argument_" + itos(i + 1);
Node *n = old_base->get_node(get(property_name));
set(property_name, p_node ? p_node->get_path_to(n) : NodePath());
}
}

void notify_changed() {
notify_property_list_changed();
}
Expand Down Expand Up @@ -176,6 +203,9 @@ void ConnectDialog::_tree_node_selected() {
if (!edit_mode) {
set_dst_method(generate_method_callback_name(source, signal, current));
}

cdbinds->update_base_node_relative(current);

_update_method_tree();
_update_warning_label();
_update_ok_enabled();
Expand Down
5 changes: 5 additions & 0 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,11 @@ void EditorPropertyNodePath::_notification(int p_what) {
Node *EditorPropertyNodePath::get_base_node() {
Node *base_node = Object::cast_to<Node>(get_edited_object());

// For proxy objects, specifies the node to which the path is relative.
if (!base_node && get_edited_object()->has_meta("__base_node_relative")) {
base_node = Object::cast_to<Node>(get_edited_object()->get_meta("__base_node_relative"));
}

if (!base_node) {
base_node = Object::cast_to<Node>(InspectorDock::get_inspector_singleton()->get_edited_object());
}
Expand Down