From be78a679a950f1d1b07f8f16c358c33ac1ccda66 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 20 Apr 2011 03:48:43 +0000 Subject: Less code. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3182 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/events/DisconnectAll.cpp | 46 ++++++++++++++++--------------------- src/engine/events/DisconnectAll.hpp | 2 +- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/engine/events/DisconnectAll.cpp b/src/engine/events/DisconnectAll.cpp index dcfb34ab..3509fd04 100644 --- a/src/engine/events/DisconnectAll.cpp +++ b/src/engine/events/DisconnectAll.cpp @@ -75,13 +75,24 @@ DisconnectAll::~DisconnectAll() } void -DisconnectAll::remove_connection(ConnectionImpl* c) +DisconnectAll::maybe_remove_connection(ConnectionImpl* c) { - _impls.push_back( - new Disconnect::Impl(_engine, - _parent, - dynamic_cast(c->src_port()), - dynamic_cast(c->dst_port()))); + if (c->pending_disconnection()) + return; + + OutputPort* src = dynamic_cast(c->src_port()); + InputPort* dst = dynamic_cast(c->dst_port()); + + if (_node) { + if (src->parent_node() == _node || dst->parent_node() == _node) { + _impls.push_back(new Disconnect::Impl(_engine, _parent, src, dst)); + } + } else { + assert(_port); + if (src == _port || dst == _port) { + _impls.push_back(new Disconnect::Impl(_engine, _parent, src, dst)); + } + } } void @@ -117,26 +128,9 @@ DisconnectAll::pre_process() assert((_node || _port) && !(_node && _port)); } - if (_node) { - for (PatchImpl::Connections::const_iterator i = _parent->connections().begin(); - i != _parent->connections().end(); ++i) { - ConnectionImpl* c = (ConnectionImpl*)i->second.get(); - 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(); - if (!c->pending_disconnection() - && (c->src_port() == _port - || c->dst_port() == _port)) { - remove_connection(c); - } - } + for (Patch::Connections::const_iterator i = _parent->connections().begin(); + i != _parent->connections().end(); ++i) { + maybe_remove_connection((ConnectionImpl*)i->second.get()); } if (!_deleting && _parent->enabled()) diff --git a/src/engine/events/DisconnectAll.hpp b/src/engine/events/DisconnectAll.hpp index aae6f84d..c4f6e6b6 100644 --- a/src/engine/events/DisconnectAll.hpp +++ b/src/engine/events/DisconnectAll.hpp @@ -70,7 +70,7 @@ private: OBJECT_NOT_FOUND, }; - void remove_connection(ConnectionImpl* c); + void maybe_remove_connection(ConnectionImpl* c); Raul::Path _parent_path; Raul::Path _path; -- cgit v1.2.1