Skip to content

Commit 2b71fb6

Browse files
committed
Fix regression in mechanism to hold objects while emitting
1 parent e67074d commit 2b71fb6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/object/object.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,10 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
12161216
uint32_t *slot_flags = nullptr;
12171217
uint32_t slot_count = 0;
12181218

1219+
// If this is a ref-counted object, prevent it from being destroyed during signal emission,
1220+
// which is needed in certain edge cases; e.g., GH-73889 and GH-109471.
1221+
Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
1222+
12191223
{
12201224
OBJ_SIGNAL_LOCK
12211225

@@ -1230,10 +1234,6 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
12301234
return ERR_UNAVAILABLE;
12311235
}
12321236

1233-
// If this is a ref-counted object, prevent it from being destroyed during signal emission,
1234-
// which is needed in certain edge cases; e.g., https://github.com/godotengine/godot/issues/73889.
1235-
Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
1236-
12371237
// Ensure that disconnecting the signal or even deleting the object
12381238
// will not affect the signal calling.
12391239
slot_callables = (Callable *)alloca(sizeof(Callable) * s->slot_map.size());

0 commit comments

Comments
 (0)