diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-14 07:53:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-14 07:53:30 +0100 |
commit | ebf28c942fab4383b04081514956f0cb9e544c7a (patch) | |
tree | 53f03ca2ab5cb61b3d7f8cad76a6a036d60d63a1 | |
parent | 34ad33d9e0b211b2de5855373f8626af4fc0ce11 (diff) | |
parent | 0aeb5bbf621d846074c0bc437e8a0f54de71d997 (diff) |
Merge pull request #35088 from akien-mga/object-disconnect-was-safe-enough
Object: Remove error on disconnect of locked signals
-rw-r--r-- | core/object.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/core/object.cpp b/core/object.cpp index 35ccc38d4e..21666a334c 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1185,13 +1185,11 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int const Connection &c = slot_map.getv(i).conn; - Object *target; -#ifdef DEBUG_ENABLED - target = ObjectDB::get_instance(slot_map.getk(i)._id); - ERR_CONTINUE(!target); -#else - target = c.target; -#endif + Object *target = ObjectDB::get_instance(slot_map.getk(i)._id); + if (!target) { + // Target might have been deleted during signal callback, this is expected and OK. + continue; + } const Variant **args = p_args; int argc = p_argcount; @@ -1519,10 +1517,6 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const Signal *s = signal_map.getptr(p_signal); ERR_FAIL_COND_MSG(!s, vformat("Nonexistent signal '%s' in %s.", p_signal, to_string())); - ERR_FAIL_COND_MSG(s->lock > 0, - vformat("Attempt to disconnect %s signal '%s' while in emission callback '%s' (in target %s). Use CONNECT_DEFERRED (to be able to safely disconnect) or CONNECT_ONESHOT (for automatic disconnection) as connection flags.", - to_string(), p_signal, p_to_method, p_to_object->to_string())); - Signal::Target target(p_to_object->get_instance_id(), p_to_method); ERR_FAIL_COND_MSG(!s->slot_map.has(target), "Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method + "."); |