summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/ConnectionModel.h4
-rw-r--r--src/libs/client/ObjectModel.h4
-rw-r--r--src/libs/client/PatchModel.cpp28
3 files changed, 26 insertions, 10 deletions
diff --git a/src/libs/client/ConnectionModel.h b/src/libs/client/ConnectionModel.h
index 6dc85405..f1112e33 100644
--- a/src/libs/client/ConnectionModel.h
+++ b/src/libs/client/ConnectionModel.h
@@ -62,8 +62,8 @@ private:
void src_port_path(const string& s) { _src_port_path = s; }
void dst_port_path(const string& s) { _dst_port_path = s; }
- Path _src_port_path; ///< Only used if _src_port == NULL
- Path _dst_port_path; ///< Only used if _dst_port == NULL
+ Path _src_port_path; ///< Only used if _src_port == NULL
+ Path _dst_port_path; ///< Only used if _dst_port == NULL
SharedPtr<PortModel> _src_port;
SharedPtr<PortModel> _dst_port;
};
diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h
index 799399e9..12db367b 100644
--- a/src/libs/client/ObjectModel.h
+++ b/src/libs/client/ObjectModel.h
@@ -55,8 +55,8 @@ public:
const Atom& get_metadata(const string& key) const;
- const MetadataMap& metadata() const { return _metadata; }
- inline const Path& path() const { return _path; }
+ const MetadataMap& metadata() const { return _metadata; }
+ inline const Path& path() const { return _path; }
SharedPtr<ObjectModel> parent() const { return _parent; }
// Signals
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) {