-
-
Notifications
You must be signed in to change notification settings - Fork 23.9k
Fix CONNECT_APPEND_SOURCE_OBJECT to bind on signal emission
#114328
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
base: master
Are you sure you want to change the base?
Fix CONNECT_APPEND_SOURCE_OBJECT to bind on signal emission
#114328
Conversation
1e219dc to
bf302c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
|
I've realized this is not a proper fix, this would break for a runtime duplication of a Node with source binded using
@tool
extends EditorScript
class Signaler:
signal sig
class Receiver:
func callback(source: Object) -> void:
print("%s.callback( source=%s )" % [self, source])
func _run() -> void:
var source := Signaler.new()
var receiver := Receiver.new()
source.sig.connect(receiver.callback, CONNECT_APPEND_SOURCE_OBJECT)
source.sig.emit() # ERROR: core/object/object.cpp:1310 - Error calling from signal 'sig' to callable: 'RefCounted::callback': Method expected 1 argument(s), but called with 0.
|
|
bf302c5 to
9f54dce
Compare
9f54dce to
49d9ffd
Compare
I've moved handling |
Node binded with CONNECT_APPEND_SOURCE_OBJECT flagCONNECT_APPEND_SOURCE_OBJECT to bind on signal emission
| } | ||
|
|
||
| if (flags & CONNECT_APPEND_SOURCE_OBJECT) { | ||
| callable_with_source_object_binded = callable_ptr->bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

Fixes #114326.
Changes
CONNECT_APPEND_SOURCE_OBJECTto bind the source object on signal emission. Previously it was done only on PackedScene instantiation, which led to bugs/inconsistencies.CONNECT_APPEND_SOURCE_OBJECTdid not work on runtime connections.Modified MRP from #114326 with the examples below: duplicate-signal-extra-arg_v2.zip
Relevant part of
control.tscnfrom #114326 MRP: