More fixes for connecting/disconnecting
git-svn-id: http://svn.drobilla.net/lad@83 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
parent
a1f30fe144
commit
93f01eb719
|
@ -209,6 +209,7 @@ PatchModel::add_connection(CountedPtr<ConnectionModel> cm)
|
|||
void
|
||||
PatchModel::remove_connection(const string& src_port_path, const string& dst_port_path)
|
||||
{
|
||||
cerr << path() << " PatchModel::remove_connection: " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl;
|
||||
for (list<CountedPtr<ConnectionModel> >::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
|
||||
CountedPtr<ConnectionModel> cm = (*i);
|
||||
if (cm->src_port_path() == src_port_path && cm->dst_port_path() == dst_port_path) {
|
||||
|
@ -218,6 +219,7 @@ PatchModel::remove_connection(const string& src_port_path, const string& dst_por
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cerr << "[PatchModel::remove_connection] WARNING: Failed to find connection " <<
|
||||
src_port_path << " -> " << dst_port_path << endl;
|
||||
}
|
||||
|
|
|
@ -365,17 +365,23 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path)
|
|||
void
|
||||
Store::disconnection_event(const Path& src_port_path, const Path& dst_port_path)
|
||||
{
|
||||
const Path& src = src_port_path;
|
||||
const Path& dst = dst_port_path;
|
||||
// Find the ports and create a ConnectionModel just to get at the parent path
|
||||
// finding logic in ConnectionModel. So I'm lazy.
|
||||
|
||||
CountedPtr<PortModel> src_port = object(src_port_path);
|
||||
CountedPtr<PortModel> dst_port = object(dst_port_path);
|
||||
|
||||
assert(src.parent().parent() == dst.parent().parent());
|
||||
const Path& patch_path = src.parent().parent();
|
||||
assert(src_port);
|
||||
assert(dst_port);
|
||||
|
||||
CountedPtr<PatchModel> patch = this->object(patch_path);
|
||||
CountedPtr<ConnectionModel> cm = new ConnectionModel(src_port, dst_port);
|
||||
|
||||
CountedPtr<PatchModel> patch = this->object(cm->patch_path());
|
||||
|
||||
if (patch)
|
||||
patch->remove_connection(src, dst);
|
||||
patch->remove_connection(src_port_path, dst_port_path);
|
||||
else
|
||||
cerr << "ERROR: connection in nonexistant patch" << endl;
|
||||
cerr << "ERROR: disconnection in nonexistant patch" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,18 +110,6 @@ DisconnectionEvent::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;
|
||||
} 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) {
|
||||
|
@ -197,20 +185,26 @@ TypedDisconnectionEvent<T>::pre_process()
|
|||
|
||||
Node* const src_node = m_src_port->parent_node();
|
||||
Node* const dst_node = m_dst_port->parent_node();
|
||||
|
||||
// Connection to a patch port from inside the 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);
|
||||
|
||||
// Connection from a patch input to a patch output (pass through)
|
||||
} else if (src_node == dst_node && dynamic_cast<Patch*>(src_node)) {
|
||||
m_patch = dynamic_cast<Patch*>(src_node);
|
||||
|
||||
// Normal connection between nodes with the same parent
|
||||
} 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;
|
||||
|
@ -250,7 +244,8 @@ TypedDisconnectionEvent<T>::execute(samplecount offset)
|
|||
if (port_connection != NULL) {
|
||||
ListNode<Connection*>* const patch_connection
|
||||
= m_patch->remove_connection(m_src_port, m_dst_port);
|
||||
|
||||
|
||||
assert(patch_connection);
|
||||
assert((Connection*)port_connection->elem() == patch_connection->elem());
|
||||
|
||||
// Clean up both the list node and the connection itself...
|
||||
|
|
Loading…
Reference in New Issue