Skip to content

Commit 76a5182

Browse files
committed
Fix regression in mechanism to hold objects while emitting
1 parent 8ebf8ae commit 76a5182

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
@@ -1221,6 +1221,10 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
12211221
uint32_t *slot_flags = slot_flags_stack;
12221222
uint32_t slot_count = 0;
12231223

1224+
// If this is a ref-counted object, prevent it from being destroyed during signal emission,
1225+
// which is needed in certain edge cases; e.g., GH-73889 and GH-109471.
1226+
Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
1227+
12241228
{
12251229
OBJ_SIGNAL_LOCK
12261230

@@ -1235,10 +1239,6 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
12351239
return ERR_UNAVAILABLE;
12361240
}
12371241

1238-
// If this is a ref-counted object, prevent it from being destroyed during signal emission,
1239-
// which is needed in certain edge cases; e.g., https://github.com/godotengine/godot/issues/73889.
1240-
Ref<RefCounted> rc = Ref<RefCounted>(Object::cast_to<RefCounted>(this));
1241-
12421242
if (s->slot_map.size() > MAX_SLOTS_ON_STACK) {
12431243
slot_callables = (Callable *)memalloc(sizeof(Callable) * s->slot_map.size());
12441244
slot_flags = (uint32_t *)memalloc(sizeof(uint32_t) * s->slot_map.size());

0 commit comments

Comments
 (0)