summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-20 03:48:43 +0000
committerDavid Robillard <d@drobilla.net>2011-04-20 03:48:43 +0000
commitbe78a679a950f1d1b07f8f16c358c33ac1ccda66 (patch)
treed5dd203efaeaa22d6b8bfb179788d5a7af7be89e /src/engine
parent40e774fc5d9bf301b3eb9acf468efacb0165cd44 (diff)
downloadingen-be78a679a950f1d1b07f8f16c358c33ac1ccda66.tar.gz
ingen-be78a679a950f1d1b07f8f16c358c33ac1ccda66.tar.bz2
ingen-be78a679a950f1d1b07f8f16c358c33ac1ccda66.zip
Less code.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3182 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/events/DisconnectAll.cpp46
-rw-r--r--src/engine/events/DisconnectAll.hpp2
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<OutputPort*>(c->src_port()),
- dynamic_cast<InputPort*>(c->dst_port())));
+ if (c->pending_disconnection())
+ return;
+
+ OutputPort* src = dynamic_cast<OutputPort*>(c->src_port());
+ InputPort* dst = dynamic_cast<InputPort*>(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;