diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-11-18 11:47:19 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-11-18 11:48:21 -0300 |
commit | 2d6b994e476f00e5725117501f6fc006eadd0d30 (patch) | |
tree | 922259f0c28f2a5d1b44e85e871a638bcac83123 /core/object.cpp | |
parent | 4a050568a28898a45cebe350f31bb2af867b32ff (diff) | |
download | redot-engine-2d6b994e476f00e5725117501f6fc006eadd0d30.tar.gz |
Massive speed up on deleting nodes, fixes #18673
Also makes the editor exit faster
Diffstat (limited to 'core/object.cpp')
-rw-r--r-- | core/object.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/core/object.cpp b/core/object.cpp index 1eff56f026..ea77090a45 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1941,30 +1941,30 @@ Object::~Object() { memdelete(script_instance); script_instance = NULL; - List<Connection> sconnections; const StringName *S = NULL; - while ((S = signal_map.next(S))) { + while ((S = signal_map.next(NULL))) { Signal *s = &signal_map[*S]; - ERR_EXPLAIN("Attempt to delete an object in the middle of a signal emission from it"); - ERR_CONTINUE(s->lock > 0); - - for (int i = 0; i < s->slot_map.size(); i++) { - - sconnections.push_back(s->slot_map.getv(i).conn); + if (s->lock) { + ERR_EXPLAIN("Attempt to delete an object in the middle of a signal emission from it"); + ERR_CONTINUE(s->lock > 0); } - } - for (List<Connection>::Element *E = sconnections.front(); E; E = E->next()) { + //brute force disconnect for performance + int slot_count = s->slot_map.size(); + const VMap<Signal::Target, Signal::Slot>::Pair *slot_list = s->slot_map.get_array(); - Connection &c = E->get(); - ERR_CONTINUE(c.source != this); //bug? + for (int i = 0; i < slot_count; i++) { + + slot_list[i].value.conn.target->connections.erase(slot_list[i].value.cE); + } - this->_disconnect(c.signal, c.target, c.method, true); + signal_map.erase(*S); } + //signals from nodes that connect to this node while (connections.size()) { Connection c = connections.front()->get(); |