diff options
author | David Robillard <d@drobilla.net> | 2011-04-20 01:36:34 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-20 01:36:34 +0000 |
commit | 7042795c8138f03124539f0efc892fe45eb2979f (patch) | |
tree | a948d182417d5959ed0b476a7bb571c257a80cdb /src | |
parent | 050def448a88bd6eafb8453d5cf60f761c06b46b (diff) | |
download | ingen-7042795c8138f03124539f0efc892fe45eb2979f.tar.gz ingen-7042795c8138f03124539f0efc892fe45eb2979f.tar.bz2 ingen-7042795c8138f03124539f0efc892fe45eb2979f.zip |
Factor out duplicated code.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3178 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/events/DisconnectAll.cpp | 34 | ||||
-rw-r--r-- | src/engine/events/DisconnectAll.hpp | 2 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/engine/events/DisconnectAll.cpp b/src/engine/events/DisconnectAll.cpp index cc5bf42d..c49cd9d7 100644 --- a/src/engine/events/DisconnectAll.cpp +++ b/src/engine/events/DisconnectAll.cpp @@ -74,6 +74,17 @@ DisconnectAll::~DisconnectAll() } void +DisconnectAll::remove_connection(ConnectionImpl* c) +{ + const bool reconnect_input = !_deleting || (c->dst_port()->parent_node() != _node); + Disconnect* ev = new Disconnect(_engine, SharedPtr<Request>(), _time, + c->src_port(), c->dst_port(), reconnect_input); + ev->pre_process(); + _disconnect_events.push_back(new Raul::List<Disconnect*>::Node(ev)); + c->pending_disconnection(true); +} + +void DisconnectAll::pre_process() { if (!_deleting) { @@ -110,27 +121,20 @@ DisconnectAll::pre_process() for (PatchImpl::Connections::const_iterator i = _parent->connections().begin(); i != _parent->connections().end(); ++i) { ConnectionImpl* c = (ConnectionImpl*)i->second.get(); - const bool reconnect_input = !_deleting || (c->dst_port()->parent_node() != _node); - if ((c->src_port()->parent_node() == _node || c->dst_port()->parent_node() == _node) - && !c->pending_disconnection()) { - Disconnect* ev = new Disconnect(_engine, - SharedPtr<Request>(), _time, c->src_port(), c->dst_port(), reconnect_input); - ev->pre_process(); - _disconnect_events.push_back(new Raul::List<Disconnect*>::Node(ev)); - c->pending_disconnection(true); + if (!c->pending_disconnection() + && (c->src_port()->parent_node() == _node + || c->dst_port()->parent_node() == _node)) { + remove_connection(c); } } } else { // _port for (PatchImpl::Connections::const_iterator i = _parent->connections().begin(); i != _parent->connections().end(); ++i) { ConnectionImpl* c = (ConnectionImpl*)i->second.get(); - const bool reconnect_input = !_deleting || (c->dst_port()->parent_node() != _node); - if ((c->src_port() == _port || c->dst_port() == _port) && !c->pending_disconnection()) { - Disconnect* ev = new Disconnect(_engine, - SharedPtr<Request>(), _time, c->src_port(), c->dst_port(), reconnect_input); - ev->pre_process(); - _disconnect_events.push_back(new Raul::List<Disconnect*>::Node(ev)); - c->pending_disconnection(true); + if (!c->pending_disconnection() + && (c->src_port() == _port + || c->dst_port() == _port)) { + remove_connection(c); } } } diff --git a/src/engine/events/DisconnectAll.hpp b/src/engine/events/DisconnectAll.hpp index 0d89901d..ee8fbade 100644 --- a/src/engine/events/DisconnectAll.hpp +++ b/src/engine/events/DisconnectAll.hpp @@ -67,6 +67,8 @@ private: OBJECT_NOT_FOUND, }; + void remove_connection(ConnectionImpl* c); + Raul::Path _parent_path; Raul::Path _path; PatchImpl* _parent; |