From 0b1c17f08f8eab4ada52ee98ba7353ec0260d3eb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Jun 2006 23:33:00 +0000 Subject: New nodes in gtk client working through Store signal interface git-svn-id: http://svn.drobilla.net/lad/grauph@26 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/PatchModel.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/libs/client/PatchModel.cpp') diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 829c9ca5..4257dd30 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -54,19 +54,21 @@ PatchModel::get_node(const string& name) { assert(name.find("/") == string::npos); NodeModelMap::iterator i = m_nodes.find(name); - return ((i != m_nodes.end()) ? (*i).second : NULL); + return ((i != m_nodes.end()) ? (*i).second.get() : NULL); } void -PatchModel::add_node(NodeModel* nm) +PatchModel::add_node(CountedPtr nm) { - assert(nm != NULL); + assert(nm); assert(nm->name().find("/") == string::npos); assert(nm->parent() == NULL); - m_nodes[nm->name()] = nm; + m_nodes[nm->name()] = CountedPtr(nm); nm->set_parent(this); + + new_node_sig.emit(nm); } @@ -76,7 +78,7 @@ PatchModel::remove_node(const string& name) assert(name.find("/") == string::npos); NodeModelMap::iterator i = m_nodes.find(name); if (i != m_nodes.end()) { - delete i->second; + //delete i->second; m_nodes.erase(i); return; } @@ -93,7 +95,7 @@ PatchModel::clear() for (NodeModelMap::iterator i = m_nodes.begin(); i != m_nodes.end(); ++i) { (*i).second->clear(); - delete (*i).second; + //delete (*i).second; } m_nodes.clear(); @@ -122,7 +124,7 @@ PatchModel::rename_node(const Path& old_path, const Path& new_path) NodeModel* nm = NULL; if (i != m_nodes.end()) { - nm = (*i).second; + nm = (*i).second.get(); for (list::iterator j = m_connections.begin(); j != m_connections.end(); ++j) { if ((*j)->src_port_path().parent() == old_path) (*j)->src_port_path(new_path.base_path() + (*j)->src_port_path().name()); @@ -172,9 +174,9 @@ PatchModel::add_connection(ConnectionModel* cm) } NodeModel* src_node = get_node(cm->src_port_path().parent().name()); - PortModel* src_port = (src_node == NULL) ? NULL : src_node->get_port(cm->src_port_path().name()); + PortModel* src_port = (src_node == NULL) ? NULL : src_node->get_port(cm->src_port_path().name()).get(); NodeModel* dst_node = get_node(cm->dst_port_path().parent().name()); - PortModel* dst_port = (dst_node == NULL) ? NULL : dst_node->get_port(cm->dst_port_path().name()); + PortModel* dst_port = (dst_node == NULL) ? NULL : dst_node->get_port(cm->dst_port_path().name()).get(); assert(src_port != NULL); assert(dst_port != NULL); -- cgit v1.2.1