diff options
author | David Robillard <d@drobilla.net> | 2006-06-21 07:03:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-06-21 07:03:30 +0000 |
commit | 90013966c14d18c7c55a906c319704bc1ffc4ae9 (patch) | |
tree | 51ec917ce77914968447358db5c1fdef954d573b /src/libs/engine/events | |
parent | adac9032064d973ff6cfe1f94d8619c71fe199a3 (diff) | |
download | ingen-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')
-rw-r--r-- | src/libs/engine/events/ConnectionEvent.cpp | 16 | ||||
-rw-r--r-- | src/libs/engine/events/ConnectionEvent.h | 1 | ||||
-rw-r--r-- | src/libs/engine/events/DisconnectionEvent.cpp | 113 | ||||
-rw-r--r-- | src/libs/engine/events/DisconnectionEvent.h | 1 |
4 files changed, 60 insertions, 71 deletions
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index 1182c723..aedfd881 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -164,19 +164,17 @@ TypedConnectionEvent<T>::TypedConnectionEvent(CountedPtr<Responder> responder, O assert(dst_port != NULL); } -template <typename T> -TypedConnectionEvent<T>::~TypedConnectionEvent() -{ - // FIXME: haaaack, prevent a double delete - // this class is unusable by anything other than ConnectionEvent because of this - //m_responder = NULL; -} - template <typename T> void TypedConnectionEvent<T>::pre_process() -{ +{ + if (m_dst_port->is_connected_to(m_src_port)) { + m_succeeded = false; + QueuedEvent::pre_process(); + return; + } + Node* const src_node = m_src_port->parent_node(); Node* const dst_node = m_dst_port->parent_node(); diff --git a/src/libs/engine/events/ConnectionEvent.h b/src/libs/engine/events/ConnectionEvent.h index 2d2e0c92..23bedcef 100644 --- a/src/libs/engine/events/ConnectionEvent.h +++ b/src/libs/engine/events/ConnectionEvent.h @@ -81,7 +81,6 @@ class TypedConnectionEvent : public QueuedEvent { public: TypedConnectionEvent(CountedPtr<Responder> responder, OutputPort<T>* src_port, InputPort<T>* dst_port); - ~TypedConnectionEvent(); void pre_process(); void execute(samplecount offset); 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(); diff --git a/src/libs/engine/events/DisconnectionEvent.h b/src/libs/engine/events/DisconnectionEvent.h index 6edbc78a..43b2d841 100644 --- a/src/libs/engine/events/DisconnectionEvent.h +++ b/src/libs/engine/events/DisconnectionEvent.h @@ -83,7 +83,6 @@ class TypedDisconnectionEvent : public QueuedEvent { public: TypedDisconnectionEvent(CountedPtr<Responder> responder, OutputPort<T>* src_port, InputPort<T>* dst_port); - ~TypedDisconnectionEvent(); void pre_process(); void execute(samplecount offset); |