Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49196 - trunk/libs/serialization/src
From: ramey_at_[hidden]
Date: 2008-10-09 02:26:42


Author: ramey
Date: 2008-10-09 02:26:41 EDT (Thu, 09 Oct 2008)
New Revision: 49196
URL: http://svn.boost.org/trac/boost/changeset/49196

Log:
Fix for important problem regarding extended_type_info tables

Text files modified:
   trunk/libs/serialization/src/extended_type_info.cpp | 18 ++++++++++++--
   trunk/libs/serialization/src/extended_type_info_typeid.cpp | 49 +++++++++++++++++++++++----------------
   2 files changed, 44 insertions(+), 23 deletions(-)

Modified: trunk/libs/serialization/src/extended_type_info.cpp
==============================================================================
--- trunk/libs/serialization/src/extended_type_info.cpp (original)
+++ trunk/libs/serialization/src/extended_type_info.cpp 2008-10-09 02:26:41 EDT (Thu, 09 Oct 2008)
@@ -58,7 +58,19 @@
     }
 };
 
-typedef std::multiset<const extended_type_info *, key_compare> ktmap;
+struct ktmap :
+ public std::multiset<const extended_type_info *, key_compare>
+{
+ static bool m_destroyed;
+ static bool is_destroyed(){
+ return m_destroyed;
+ }
+ ~ktmap(){
+ m_destroyed = true;
+ }
+};
+
+bool ktmap::m_destroyed = false;
 
 class extended_type_info_arg : public extended_type_info
 {
@@ -85,7 +97,7 @@
 BOOST_SERIALIZATION_DECL(void)
 extended_type_info::key_unregister() {
     assert(NULL != m_key);
- if(! singleton<detail::ktmap>::is_destroyed()){
+ if(detail::ktmap::is_destroyed()){
         detail::ktmap & x = singleton<detail::ktmap>::get_mutable_instance();
         detail::ktmap::iterator start = x.lower_bound(this);
         detail::ktmap::iterator end = x.upper_bound(this);
@@ -96,7 +108,7 @@
             if(this == *start)
                 x.erase(start++);
             else
- ++start;
+ ++start;
         }while(start != end);
     }
     m_key = NULL;

Modified: trunk/libs/serialization/src/extended_type_info_typeid.cpp
==============================================================================
--- trunk/libs/serialization/src/extended_type_info_typeid.cpp (original)
+++ trunk/libs/serialization/src/extended_type_info_typeid.cpp 2008-10-09 02:26:41 EDT (Thu, 09 Oct 2008)
@@ -39,11 +39,20 @@
     }
 };
 
-typedef std::multiset<
- const extended_type_info_typeid_0 *,
- type_compare
-> tkmap;
-
+struct tkmap :
+ public std::multiset<const extended_type_info_typeid_0 *,type_compare>
+{
+ static bool m_destroyed;
+ static bool is_destroyed(){
+ return m_destroyed;
+ }
+ ~tkmap(){
+ m_destroyed = true;
+ }
+};
+
+bool tkmap::m_destroyed = false;
+
 BOOST_SERIALIZATION_DECL(bool)
 extended_type_info_typeid_0::is_less_than(
     const boost::serialization::extended_type_info & rhs
@@ -82,21 +91,21 @@
 BOOST_SERIALIZATION_DECL(void)
 extended_type_info_typeid_0::type_unregister()
 {
- if(NULL == m_ti){
- if(! singleton<tkmap>::is_destroyed()){
- tkmap & x = singleton<tkmap>::get_mutable_instance();
- tkmap::iterator start = x.lower_bound(this);
- tkmap::iterator end = x.upper_bound(this);
- assert(start != end);
-
- // remove entry in map which corresponds to this type
- do{
- if(this == *start)
- x.erase(start++);
- else
- ++start;
- }while(start != end);
- }
+ if(NULL == m_ti)
+ return;
+ if(! tkmap::is_destroyed()){
+ tkmap & x = singleton<tkmap>::get_mutable_instance();
+ tkmap::iterator start = x.lower_bound(this);
+ tkmap::iterator end = x.upper_bound(this);
+ assert(start != end);
+
+ // remove entry in map which corresponds to this type
+ do{
+ if(this == *start)
+ x.erase(start++);
+ else
+ ++start;
+ }while(start != end);
     }
     m_ti = NULL;
 }


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