Issue more precise error when disconnecting a nonexistent connection

Checks whether the signal exists when issuing an error message when
disconnecting a nonexistent connection. Also prints the callable name.

(cherry picked from commit 6c026a6814)
This commit is contained in:
Maganty Rushyendra 2020-12-31 18:33:39 +08:00 committed by Rémi Verschelde
parent 927010e90f
commit bc564cd661
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1563,7 +1563,13 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const
ERR_FAIL_NULL(p_to_object); ERR_FAIL_NULL(p_to_object);
Signal *s = signal_map.getptr(p_signal); Signal *s = signal_map.getptr(p_signal);
ERR_FAIL_COND_MSG(!s, vformat("Nonexistent signal '%s' in %s.", p_signal, to_string())); if (!s) {
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal) ||
(!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal));
ERR_FAIL_COND_MSG(signal_is_valid, vformat("Attempt to disconnect a nonexistent connection to signal '%s' in %s, with target '%s' in %s.",
p_signal, to_string(), p_to_method, p_to_object->to_string()));
}
ERR_FAIL_COND_MSG(!s, vformat("Disconnecting nonexistent signal '%s' in %s.", p_signal, to_string()));
Signal::Target target(p_to_object->get_instance_id(), p_to_method); Signal::Target target(p_to_object->get_instance_id(), p_to_method);