From c251404656f01e920ffe343ebeef0fd778ac65ba Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 27 Apr 2010 01:14:03 +0000 Subject: [PATCH] workaround for double-destruction bugs in compilers: with this, boost::exception objects should survive the case when the destructor is called twice. [SVN r61602] --- include/boost/exception/exception.hpp | 6 +++--- include/boost/exception/info.hpp | 9 +++++++-- test/refcount_ptr_test.cpp | 9 +++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index fd516dd..2ca2790 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -75,8 +75,8 @@ boost void release() { - if( px_ ) - px_->release(); + if( px_ && px_->release() ) + px_=0; } }; } @@ -150,7 +150,7 @@ boost virtual shared_ptr get( type_info_ const & ) const = 0; virtual void set( shared_ptr const &, type_info_ const & ) = 0; virtual void add_ref() const = 0; - virtual void release() const = 0; + virtual bool release() const = 0; virtual refcount_ptr clone() const = 0; protected: diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index 7aeeee5..dbc44c3 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -140,11 +140,16 @@ boost ++count_; } - void + bool release() const { - if( !--count_ ) + if( --count_ ) + return false; + else + { delete this; + return true; + } } refcount_ptr diff --git a/test/refcount_ptr_test.cpp b/test/refcount_ptr_test.cpp index 773d784..283f570 100644 --- a/test/refcount_ptr_test.cpp +++ b/test/refcount_ptr_test.cpp @@ -28,11 +28,16 @@ test_type ++count_; } - void + bool release() { - if( !--count_ ) + if( --count_ ) + return false; + else + { delete this; + return true; + } } private: