|
Boost-Commit : |
From: pdimov_at_[hidden]
Date: 2008-03-25 11:46:40
Author: pdimov
Date: 2008-03-25 11:46:40 EDT (Tue, 25 Mar 2008)
New Revision: 43856
URL: http://svn.boost.org/trac/boost/changeset/43856
Log:
_internal_accept_owner now checks if _owned isn't already true.
Text files modified:
trunk/boost/enable_shared_from_this.hpp | 16 ++++++++++++----
trunk/libs/smart_ptr/test/esft_regtest.cpp | 12 ++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
Modified: trunk/boost/enable_shared_from_this.hpp
==============================================================================
--- trunk/boost/enable_shared_from_this.hpp (original)
+++ trunk/boost/enable_shared_from_this.hpp 2008-03-25 11:46:40 EDT (Tue, 25 Mar 2008)
@@ -94,10 +94,18 @@
void _internal_accept_owner(shared_ptr<U> &owner) const
{
init_internal_shared_once();
- get_deleter<detail::sp_deleter_wrapper>(_internal_shared_this)->set_deleter(owner);
- owner.reset( _internal_shared_this, owner.get() );
- _internal_shared_this.reset();
- _owned = true;
+
+ if( !_owned )
+ {
+ detail::sp_deleter_wrapper * pd = get_deleter<detail::sp_deleter_wrapper>(_internal_shared_this);
+ BOOST_ASSERT( pd != 0 );
+ pd->set_deleter(owner);
+
+ owner.reset( _internal_shared_this, owner.get() );
+ _internal_shared_this.reset();
+
+ _owned = true;
+ }
}
};
Modified: trunk/libs/smart_ptr/test/esft_regtest.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/esft_regtest.cpp (original)
+++ trunk/libs/smart_ptr/test/esft_regtest.cpp 2008-03-25 11:46:40 EDT (Tue, 25 Mar 2008)
@@ -162,11 +162,23 @@
BOOST_TEST( pv.get() == p );
}
+struct null_deleter
+{
+ void operator()( void const* ) const {}
+};
+
+void test4()
+{
+ boost::shared_ptr<V> pv( new V );
+ boost::shared_ptr<V> pv2( pv.get(), null_deleter() );
+}
+
int main()
{
test();
test2();
test3();
+ test4();
return boost::report_errors();
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk