Fix edge cases of object lifetime when signals involved
This commit is contained in:
parent
59b8c70007
commit
2f4168daeb
5 changed files with 30 additions and 1 deletions
|
|
@ -1013,6 +1013,10 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
|
|||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
// If this is a ref-counted object, prevent it from being destroyed during signal emission,
|
||||
// which is needed in certain edge cases; e.g., https://github.com/godotengine/godot/issues/73889.
|
||||
Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
|
||||
|
||||
List<_ObjectSignalDisconnectData> disconnect_data;
|
||||
|
||||
//copy on write will ensure that disconnecting the signal or even deleting the object will not affect the signal calling.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue