Skip to content

Commit cdfeeb7

Browse files
committed
Fix non-tool script check when emitting signals
1 parent fdbf6ec commit cdfeeb7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/object/object.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -1246,14 +1246,18 @@ Error Object::emit_signalp(const StringName &p_name, const Variant **p_args, int
12461246
_emitting = false;
12471247

12481248
if (ce.error != Callable::CallError::CALL_OK) {
1249-
#ifdef DEBUG_ENABLED
1250-
if (flags & CONNECT_PERSIST && Engine::get_singleton()->is_editor_hint() && (script.is_null() || !Ref<Script>(script)->is_tool())) {
1251-
continue;
1249+
Object *target = callable.get_object();
1250+
#ifdef TOOLS_ENABLED
1251+
if (target && flags & CONNECT_PERSIST && Engine::get_singleton()->is_editor_hint()) {
1252+
Ref<Script> other_scr = target->get_script();
1253+
if (other_scr.is_valid() && !other_scr->is_tool()) {
1254+
// Trying to call not-tool method in editor, just ignore it.
1255+
continue;
1256+
}
12521257
}
12531258
#endif
1254-
Object *target = callable.get_object();
12551259
if (ce.error == Callable::CallError::CALL_ERROR_INVALID_METHOD && target && !ClassDB::class_exists(target->get_class_name())) {
1256-
//most likely object is not initialized yet, do not throw error.
1260+
// Most likely object is not initialized yet, do not throw error.
12571261
} else {
12581262
ERR_PRINT(vformat("Error calling from signal '%s' to callable: %s.", String(p_name), Variant::get_callable_error_text(callable, args, argc, ce)));
12591263
err = ERR_METHOD_NOT_FOUND;

0 commit comments

Comments
 (0)