summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorjcorgan2009-04-17 18:45:58 +0000
committerjcorgan2009-04-17 18:45:58 +0000
commite6fbd962e13459e87c084d27b5fdf54fda88af81 (patch)
treedb73ed83d2f789f6a34ccb1ea83e77e63341f003 /gnuradio-core/src/lib
parentf0282d9fdf1a5e18aa4f1717843befe4d147ffb7 (diff)
downloadgnuradio-e6fbd962e13459e87c084d27b5fdf54fda88af81.tar.gz
gnuradio-e6fbd962e13459e87c084d27b5fdf54fda88af81.tar.bz2
gnuradio-e6fbd962e13459e87c084d27b5fdf54fda88af81.zip
Fixes ticket:386
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10869 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc38
1 files changed, 33 insertions, 5 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
index c6cbd5b31..1c437d3c8 100644
--- a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
+++ b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
@@ -146,16 +146,44 @@ gr_hier_block2_detail::connect(gr_basic_block_sptr src, int src_port,
void
gr_hier_block2_detail::disconnect(gr_basic_block_sptr block)
{
+ // Check on singleton list
for (gr_basic_block_viter_t p = d_blocks.begin(); p != d_blocks.end(); p++) {
if (*p == block) {
d_blocks.erase(p);
+
+ gr_hier_block2_sptr hblock(cast_to_hier_block2_sptr(block));
+ if (block && block.get() != d_owner) {
+ if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+ std::cout << "disconnect: block is hierarchical, clearing parent" << std::endl;
+ hblock->d_detail->d_parent_detail = 0;
+ }
+
return;
}
}
- std::stringstream msg;
- msg << "cannot disconnect block " << block << ", not found";
- throw std::invalid_argument(msg.str());
+ // Otherwise find all edges containing block
+ gr_edge_vector_t edges, tmp = d_fg->edges();
+ gr_edge_vector_t::iterator p;
+ for (p = tmp.begin(); p != tmp.end(); p++) {
+ if ((*p).src().block() == block || (*p).dst().block() == block) {
+ edges.push_back(*p);
+
+ if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+ std::cout << "disconnect: block found in edge " << (*p) << std::endl;
+ }
+ }
+
+ if (edges.size() == 0) {
+ std::stringstream msg;
+ msg << "cannot disconnect block " << block << ", not found";
+ throw std::invalid_argument(msg.str());
+ }
+
+ for (p = edges.begin(); p != edges.end(); p++) {
+ disconnect((*p).src().block(), (*p).src().port(),
+ (*p).dst().block(), (*p).dst().port());
+ }
}
void
@@ -174,13 +202,13 @@ gr_hier_block2_detail::disconnect(gr_basic_block_sptr src, int src_port,
if (src_block && src.get() != d_owner) {
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
- std::cout << "connect: src is hierarchical, clearing parent" << std::endl;
+ std::cout << "disconnect: src is hierarchical, clearing parent" << std::endl;
src_block->d_detail->d_parent_detail = 0;
}
if (dst_block && dst.get() != d_owner) {
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
- std::cout << "connect: dst is hierarchical, clearing parent" << std::endl;
+ std::cout << "disconnect: dst is hierarchical, clearing parent" << std::endl;
dst_block->d_detail->d_parent_detail = 0;
}