diff options
author | David Robillard <d@drobilla.net> | 2007-01-08 02:41:36 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-01-08 02:41:36 +0000 |
commit | c5218b13bac00fbd8c3ceb99b46063b98bc1fdd3 (patch) | |
tree | cedcc8e24a0db8d0a40bcfececc25e66df2387e1 /src/libs/client/PatchModel.cpp | |
parent | 813e0cbb39809d7cf837e6b91a75815079502f47 (diff) | |
download | ingen-c5218b13bac00fbd8c3ceb99b46063b98bc1fdd3.tar.gz ingen-c5218b13bac00fbd8c3ceb99b46063b98bc1fdd3.tar.bz2 ingen-c5218b13bac00fbd8c3ceb99b46063b98bc1fdd3.zip |
Fix destruction of nodes with connections to parent patch ports.
git-svn-id: http://svn.drobilla.net/lad/ingen@241 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/PatchModel.cpp')
-rw-r--r-- | src/libs/client/PatchModel.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 22d39d42..1148ff61 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -124,14 +124,31 @@ PatchModel::remove_node(SharedPtr<NodeModel> nm) NodeModelMap::iterator i = m_nodes.find(nm->path().name()); if (i != m_nodes.end()) { assert(i->second == nm); + + // Remove any connections which referred to this node, + // since they can't possibly exist anymore + for (list<SharedPtr<ConnectionModel> >::iterator i = m_connections.begin(); + i != m_connections.end() ; ) { + list<SharedPtr<ConnectionModel> >::iterator next = i; + ++next; + SharedPtr<ConnectionModel> cm = (*i); + if (cm->src_port_path().parent() == nm->path() + || cm->dst_port_path().parent() == nm->path()) { + m_connections.erase(i); // cuts our reference + assert(!get_connection(cm->src_port_path(), cm->dst_port_path())); // no duplicates + removed_connection_sig.emit(cm->src_port_path(), cm->dst_port_path()); + } + i = next; + } + + // Remove the Node itself m_nodes.erase(i); removed_node_sig.emit(nm); - //i->second->parent().reset(); - return; + + } else { + cerr << "[PatchModel::remove_node] " << _path + << ": failed to find node " << nm->path().name() << endl; } - - cerr << "[PatchModel::remove_node] " << _path - << ": failed to find node " << nm->path().name() << endl; } #if 0 @@ -255,7 +272,6 @@ PatchModel::add_connection(SharedPtr<ConnectionModel> cm) void PatchModel::remove_connection(const string& src_port_path, const string& dst_port_path) { - cerr << path() << " PatchModel::remove_connection: " << src_port_path << " -> " << dst_port_path << endl; for (list<SharedPtr<ConnectionModel> >::iterator i = m_connections.begin(); i != m_connections.end(); ++i) { SharedPtr<ConnectionModel> cm = (*i); if (cm->src_port_path() == src_port_path && cm->dst_port_path() == dst_port_path) { |