summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events/DisconnectionEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-21 07:03:30 +0000
committerDavid Robillard <d@drobilla.net>2006-06-21 07:03:30 +0000
commit90013966c14d18c7c55a906c319704bc1ffc4ae9 (patch)
tree51ec917ce77914968447358db5c1fdef954d573b /src/libs/engine/events/DisconnectionEvent.cpp
parentadac9032064d973ff6cfe1f94d8619c71fe199a3 (diff)
downloadingen-90013966c14d18c7c55a906c319704bc1ffc4ae9.tar.gz
ingen-90013966c14d18c7c55a906c319704bc1ffc4ae9.tar.bz2
ingen-90013966c14d18c7c55a906c319704bc1ffc4ae9.zip
More renaming, fixed bugs with disconnecting patch ports internally
git-svn-id: http://svn.drobilla.net/lad/ingen@74 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events/DisconnectionEvent.cpp')
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp113
1 files changed, 53 insertions, 60 deletions
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index 04193c6c..f3524500 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -78,61 +78,63 @@ void
DisconnectionEvent::pre_process()
{
if (m_lookup) {
- if (m_src_port_path.parent().parent() != m_dst_port_path.parent().parent()) {
+ if (m_src_port_path.parent().parent() != m_dst_port_path.parent().parent()
+ && m_src_port_path.parent() != m_dst_port_path.parent().parent()
+ && m_src_port_path.parent().parent() != m_dst_port_path.parent()) {
m_error = PARENT_PATCH_DIFFERENT;
QueuedEvent::pre_process();
return;
}
-
+
/*m_patch = om->object_store()->find_patch(m_src_port_path.parent().parent());
-
- if (m_patch == NULL) {
- m_error = PORT_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }*/
-
- Port* port1 = om->object_store()->find_port(m_src_port_path);
- Port* port2 = om->object_store()->find_port(m_dst_port_path);
-
- if (port1 == NULL || port2 == NULL) {
+
+ if (m_patch == NULL) {
+ m_error = PORT_NOT_FOUND;
+ QueuedEvent::pre_process();
+ return;
+ }*/
+
+ m_src_port = om->object_store()->find_port(m_src_port_path);
+ m_dst_port = om->object_store()->find_port(m_dst_port_path);
+
+ if (m_src_port == NULL || m_dst_port == NULL) {
m_error = PORT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
-
- if (port1->type() != port2->type()) {
+
+ if (m_src_port->type() != m_dst_port->type() || m_src_port->buffer_size() != m_dst_port->buffer_size()) {
m_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
}
-
- if (port1->is_output() && port2->is_input()) {
- m_src_port = port1;
- m_dst_port = port2;
- } else if (port2->is_output() && port1->is_input()) {
- m_src_port = port2;
- m_dst_port = port1;
+
+ /*if (port1->is_output() && port2->is_input()) {
+ m_src_port = port1;
+ m_dst_port = port2;
+ } else if (port2->is_output() && port1->is_input()) {
+ m_src_port = port2;
+ m_dst_port = port1;
+ } else {
+ m_error = TYPE_MISMATCH;
+ QueuedEvent::pre_process();
+ return;
+ }*/
+
+ // Create the typed event to actually do the work
+ const DataType type = m_src_port->type();
+ if (type == DataType::FLOAT) {
+ m_typed_event = new TypedDisconnectionEvent<sample>(m_responder,
+ dynamic_cast<OutputPort<sample>*>(m_src_port), dynamic_cast<InputPort<sample>*>(m_dst_port));
+ } else if (type == DataType::MIDI) {
+ m_typed_event = new TypedDisconnectionEvent<MidiMessage>(m_responder,
+ dynamic_cast<OutputPort<MidiMessage>*>(m_src_port), dynamic_cast<InputPort<MidiMessage>*>(m_dst_port));
} else {
m_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
}
}
-
- // Create the typed event to actually do the work
- const DataType type = m_src_port->type();
- if (type == DataType::FLOAT) {
- m_typed_event = new TypedDisconnectionEvent<sample>(m_responder,
- dynamic_cast<OutputPort<sample>*>(m_src_port), dynamic_cast<InputPort<sample>*>(m_dst_port));
- } else if (type == DataType::MIDI) {
- m_typed_event = new TypedDisconnectionEvent<MidiMessage>(m_responder,
- dynamic_cast<OutputPort<MidiMessage>*>(m_src_port), dynamic_cast<InputPort<MidiMessage>*>(m_dst_port));
- } else {
- m_error = TYPE_MISMATCH;
- QueuedEvent::pre_process();
- return;
- }
m_typed_event->pre_process();
@@ -157,7 +159,7 @@ DisconnectionEvent::post_process()
m_typed_event->post_process();
} else {
// FIXME: better error messages
- string msg = "Unable to make connection ";
+ string msg = "Unable to disconnect ";
msg.append(m_src_port_path + " -> " + m_dst_port_path);
m_responder->respond_error(msg);
}
@@ -181,14 +183,6 @@ TypedDisconnectionEvent<T>::TypedDisconnectionEvent(CountedPtr<Responder> respon
assert(dst_port != NULL);
}
-template <typename T>
-TypedDisconnectionEvent<T>::~TypedDisconnectionEvent()
-{
- // FIXME: haaaack, prevent a double delete
- // this class is unusable by anything other than DisconnectionEvent because of this
- //m_responder = NULL;
-}
-
template <typename T>
void
@@ -202,8 +196,20 @@ TypedDisconnectionEvent<T>::pre_process()
Node* const src_node = m_src_port->parent_node();
Node* const dst_node = m_dst_port->parent_node();
-
- m_patch = src_node->parent_patch();
+ if (src_node->parent_patch() != dst_node->parent_patch()) {
+ // Connection to a patch port from inside the patch
+ assert(src_node->parent() == dst_node || dst_node->parent() == src_node);
+ if (src_node->parent() == dst_node)
+ m_patch = dynamic_cast<Patch*>(dst_node);
+ else
+ m_patch = dynamic_cast<Patch*>(src_node);
+ } else {
+ // Normal connection between nodes with the same parent
+ m_patch = src_node->parent_patch();
+ }
+
+ assert(m_patch);
+ assert(m_patch == src_node->parent() || m_patch == dst_node->parent());
if (src_node == NULL || dst_node == NULL) {
m_succeeded = false;
@@ -211,30 +217,17 @@ TypedDisconnectionEvent<T>::pre_process()
return;
}
- if (src_node->parent() != m_patch || dst_node->parent() != m_patch) {
- m_succeeded = false;
- QueuedEvent::pre_process();
- return;
- }
-
- bool removed = false;
-
for (List<Node*>::iterator i = dst_node->providers()->begin(); i != dst_node->providers()->end(); ++i)
if ((*i) == src_node) {
delete dst_node->providers()->remove(i);
- removed = true;
break;
}
- assert(removed);
- removed = false;
for (List<Node*>::iterator i = src_node->dependants()->begin(); i != src_node->dependants()->end(); ++i)
if ((*i) == dst_node) {
delete src_node->dependants()->remove(i);
- removed = true;
break;
}
- assert(removed);
if (m_patch->process())
m_process_order = m_patch->build_process_order();