summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/hier_block2.cc
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2016-01-27 11:24:19 +0100
committerJohnathan Corgan <johnathan@corganlabs.com>2016-01-27 13:09:34 -0800
commit11973c64437683cc99c48eae9eb4db8234f1ac42 (patch)
tree54059f5e91babef20f114ed81629c82a0d4a0244 /gnuradio-runtime/lib/hier_block2.cc
parent6e482c5bb6bf49f000f6b8d35a1ca84127e38c46 (diff)
gnuradio-runtime: Fix sptr magic when exception thrown in hier2 constructor
Fixes #528 Previously, if an exception is thrown in constructor of a hier_block2 subclass, then : - The hier_block2 base destructor _will_ be called - The actual object is destroyed - But the initial sptr would be left in the static map and point to an invalid object - Whatever connection() were made might have an invalid sptr ref as well So to fix this: - In the hier_block2 destructor, we explicitely disconnect() everything - In the base hier_block2 destructor, we call a new 'cancel sptr' method that will check if this object is still in the static map or not - If it's not: Then this is a legit call to the destructor by shared_ptr and everything is fine - If it's: Then there was an isue and the object is already being destroyed and we need to make sure shared_ptr doesn't try to do it again. We do this using a special 'disarmable' custom deleter. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'gnuradio-runtime/lib/hier_block2.cc')
-rw-r--r--gnuradio-runtime/lib/hier_block2.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/hier_block2.cc b/gnuradio-runtime/lib/hier_block2.cc
index eeb5669da5..597ae032ec 100644
--- a/gnuradio-runtime/lib/hier_block2.cc
+++ b/gnuradio-runtime/lib/hier_block2.cc
@@ -57,6 +57,8 @@ namespace gr {
hier_block2::~hier_block2()
{
+ disconnect_all();
+ gnuradio::detail::sptr_magic::cancel_initial_sptr(this);
delete d_detail;
}