summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2021-09-19 18:55:23 +0200
committerkobewi <kobewi4e@gmail.com>2021-09-24 17:07:33 +0200
commit7bf5fc709e7efe4bd23d8986e72165f51c945402 (patch)
tree8efa3db32d69a832a01890c1f67a30a62f8bbcc0
parent0e5b0c025ce3d4ad8082cbeb5394423854c2e25f (diff)
Remove binds from Signal.connect
-rw-r--r--core/variant/callable.cpp4
-rw-r--r--core/variant/callable.h2
-rw-r--r--core/variant/variant_call.cpp2
-rw-r--r--doc/classes/Signal.xml14
-rw-r--r--modules/gdscript/gdscript_vm.cpp2
5 files changed, 15 insertions, 9 deletions
diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp
index f487e718f4..dcded6e61f 100644
--- a/core/variant/callable.cpp
+++ b/core/variant/callable.cpp
@@ -377,11 +377,11 @@ Error Signal::emit(const Variant **p_arguments, int p_argcount) const {
return obj->emit_signal(name, p_arguments, p_argcount);
}
-Error Signal::connect(const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
+Error Signal::connect(const Callable &p_callable, uint32_t p_flags) {
Object *object = get_object();
ERR_FAIL_COND_V(!object, ERR_UNCONFIGURED);
- return object->connect(name, p_callable, p_binds, p_flags);
+ return object->connect(name, p_callable, varray(), p_flags);
}
void Signal::disconnect(const Callable &p_callable) {
diff --git a/core/variant/callable.h b/core/variant/callable.h
index 52094af3aa..de886492ea 100644
--- a/core/variant/callable.h
+++ b/core/variant/callable.h
@@ -159,7 +159,7 @@ public:
operator String() const;
Error emit(const Variant **p_arguments, int p_argcount) const;
- Error connect(const Callable &p_callable, const Vector<Variant> &p_binds = Vector<Variant>(), uint32_t p_flags = 0);
+ Error connect(const Callable &p_callable, uint32_t p_flags = 0);
void disconnect(const Callable &p_callable);
bool is_connected(const Callable &p_callable) const;
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 49a0b455df..5c43be741e 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -1688,7 +1688,7 @@ static void _register_variant_builtin_methods() {
bind_method(Signal, get_object_id, sarray(), varray());
bind_method(Signal, get_name, sarray(), varray());
- bind_method(Signal, connect, sarray("callable", "binds", "flags"), varray(Array(), 0));
+ bind_method(Signal, connect, sarray("callable", "flags"), varray(0));
bind_method(Signal, disconnect, sarray("callable"), varray());
bind_method(Signal, is_connected, sarray("callable"), varray());
bind_method(Signal, get_connections, sarray(), varray());
diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml
index 11107c093d..3845b3f20d 100644
--- a/doc/classes/Signal.xml
+++ b/doc/classes/Signal.xml
@@ -32,10 +32,16 @@
<method name="connect">
<return type="int" />
<argument index="0" name="callable" type="Callable" />
- <argument index="1" name="binds" type="Array" default="[]" />
- <argument index="2" name="flags" type="int" default="0" />
- <description>
- Connects this signal to the specified [Callable], optionally providing binds and connection flags.
+ <argument index="1" name="flags" type="int" default="0" />
+ <description>
+ Connects this signal to the specified [Callable], optionally providing connection flags. You can provide additional arguments to the connected method call by using [method Callable.bind].
+ [codeblock]
+ for button in $Buttons.get_children():
+ button.pressed.connect(on_pressed.bind(button))
+
+ func on_pressed(button):
+ print(button.name, " was pressed")
+ [/codeblock]
</description>
</method>
<method name="disconnect">
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index bf21c8510a..9ea9fc61de 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -2138,7 +2138,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
retvalue = gdfs;
- Error err = sig.connect(Callable(gdfs.ptr(), "_signal_callback"), varray(gdfs), Object::CONNECT_ONESHOT);
+ Error err = sig.connect(callable_bind(Callable(gdfs.ptr(), "_signal_callback"), retvalue), Object::CONNECT_ONESHOT);
if (err != OK) {
err_text = "Error connecting to signal: " + sig.get_name() + " during await.";
OPCODE_BREAK;