Skip to content

Commit

Permalink
GH-179 Function Call Target pin no longer autowired
Browse files Browse the repository at this point in the history
There are situations where a function signature may contain multiple pins
that would match the autowire criteria, and we should automatically skip
the `Target` pin because its generally never intended to be what will be
autowired.
  • Loading branch information
Naros committed Mar 23, 2024
1 parent b19db62 commit 1590194
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/editor/graph/graph_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ void OrchestratorGraphEdit::_attempt_autowire(const Ref<OScriptNode>& p_new_node
if (!pin.is_valid() || pin->get_flags().has_flag(OScriptNodePin::Flags::HIDDEN))
continue;

// Skip pins that are specifically flagged as non-autowirable
if (pin->get_flags().has_flag(OScriptNodePin::Flags::NO_AUTOWIRE))
continue;

// If pin direction matches drag, skip
if (_drag_context.get_direction() == pin->get_direction())
continue;
Expand Down
1 change: 1 addition & 0 deletions src/script/node_pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class OScriptNodePin : public Resource
SHOW_LABEL = 1 << 9, //! Label should be shown, always
HIDE_LABEL = 1 << 10, //! Label should be hidden, always
NO_CAPITALIZE = 1 << 11, //! Label is not capitalized
NO_AUTOWIRE = 1 << 12, //! Prevents being autowired
CONST = 1 << 20, //! Represents a "const" data port
REFERENCE = 1 << 21, //! Represents a "reference" data port
OBJECT = 1 << 22, //! Refers to an object type
Expand Down
2 changes: 1 addition & 1 deletion src/script/nodes/functions/call_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void OScriptNodeCallFunction::_create_pins_for_method(const MethodInfo& p_method
{
Variant::Type target_type = _reference.target_type != Variant::NIL ? _reference.target_type : Variant::OBJECT;
Ref<OScriptNodePin> target = create_pin(PD_Input, "target", target_type);
target->set_flags(OScriptNodePin::Flags::DATA);
target->set_flags(OScriptNodePin::Flags::DATA | OScriptNodePin::Flags::NO_AUTOWIRE);
if (_reference.target_type == Variant::NIL)
{
if (_function_flags.has_flag(FF_IS_SELF))
Expand Down

0 comments on commit 1590194

Please sign in to comment.