From 428ccb2218464a33923b3e576ad42af21468c82d Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Tue, 2 Nov 2010 15:59:51 -0400
Subject: Adding some protection to the nitems read/written accessors. Should
 this return 0 or throw?

---
 gnuradio-core/src/lib/runtime/gr_block.cc | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'gnuradio-core/src')

diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc
index f3e0ecc916..e0a223135b 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block.cc
@@ -120,13 +120,25 @@ gr_block::fixed_rate_noutput_to_ninput(int noutput)
 gr_uint64
 gr_block::n_items_read(unsigned int which_input) 
 {
-  return d_detail->n_items_read(which_input);
+  if(d_detail) {
+    return d_detail->n_items_read(which_input);
+  }
+  else {
+    //throw std::runtime_error("No block_detail associated with block yet");
+    return 0;
+  }
 }
 
 gr_uint64
 gr_block::n_items_written(unsigned int which_output) 
 {
-  return d_detail->n_items_written(which_output);
+  if(d_detail) {
+    return d_detail->n_items_written(which_output);
+  }
+  else {
+    //throw std::runtime_error("No block_detail associated with block yet");
+    return 0;
+  }
 }
 
 void
-- 
cgit v1.2.3