From c5218b13bac00fbd8c3ceb99b46063b98bc1fdd3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 8 Jan 2007 02:41:36 +0000 Subject: 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 --- src/progs/ingenuity/PatchCanvas.cpp | 57 +++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'src/progs') diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp index f7c80987..d305e9c3 100644 --- a/src/progs/ingenuity/PatchCanvas.cpp +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -163,41 +163,56 @@ PatchCanvas::connection(SharedPtr cm) const Path& src_parent_path = cm->src_port_path().parent(); const Path& dst_parent_path = cm->dst_port_path().parent(); - const string& src_parent_name = - (src_parent_path == m_patch->path()) ? "" : src_parent_path.name(); - const string& dst_parent_name = - (dst_parent_path == m_patch->path()) ? "" : dst_parent_path.name(); + const string& src_parent_name = (src_parent_path == m_patch->path()) + ? cm->src_port_path().name() + : src_parent_path.name(); + + const string& dst_parent_name = (dst_parent_path == m_patch->path()) + ? cm->dst_port_path().name() + : dst_parent_path.name(); boost::shared_ptr src = get_port(src_parent_name, cm->src_port_path().name()); boost::shared_ptr dst = get_port(dst_parent_name, cm->dst_port_path().name()); - if (src && dst) { - add_connection(boost::shared_ptr( - new Connection(shared_from_this(), cm, src, dst))); - } else { - cerr << "[Canvas] ERROR: Unable to find ports to create connection." << endl; - } + cerr << "SPN: " << src_parent_name << endl; + cerr << "DPN: " << dst_parent_name << endl; + + if (src && dst) + add_connection(boost::shared_ptr(new Connection(shared_from_this(), cm, src, dst))); + else + cerr << "[PatchCanvas] ERROR: Unable to find ports to connect " + << cm->src_port_path() << " -> " << cm->dst_port_path() << endl; } void PatchCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path) { - const string& src_node_name = src_port_path.parent().name(); - const string& src_port_name = src_port_path.name(); - const string& dst_node_name = dst_port_path.parent().name(); - const string& dst_port_name = dst_port_path.name(); + // Deal with port "anonymous nodes" for this patch's own ports... + const Path& src_parent_path = src_port_path.parent(); + const Path& dst_parent_path = dst_port_path.parent(); - boost::shared_ptr src_port = get_port(src_node_name, src_port_name); - boost::shared_ptr dst_port = get_port(dst_node_name, dst_port_name); + const string& src_parent_name = (src_parent_path == m_patch->path()) + ? src_port_path.name() + : src_parent_path.name(); - if (src_port && dst_port) { - remove_connection(src_port, dst_port); - } + const string& dst_parent_name = (dst_parent_path == m_patch->path()) + ? dst_port_path.name() + : dst_parent_path.name(); + + cerr << "SPN: " << src_parent_name << endl; + cerr << "DPN: " << dst_parent_name << endl; - //patch_model()->remove_connection(src_port_path, dst_port_path); + boost::shared_ptr src = get_port(src_parent_name, src_port_path.name()); + boost::shared_ptr dst = get_port(dst_parent_name, dst_port_path.name()); + + if (src && dst) + remove_connection(src, dst); + else + cerr << "[PatchCanvas] ERROR: Unable to find ports to disconnect " + << src_port_path << " -> " << dst_port_path << endl; - cerr << "FIXME: disconnection\n"; + cerr << "FIXME: disconnection control window stuff\n"; /* // Enable control slider in destination node control window PortController* p = (PortController)Store::instance().port(dst_port_path)->controller(); -- cgit v1.2.1