Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55263 - sandbox/pinhole/boost/pinhole
From: jmcintyre_at_[hidden]
Date: 2009-07-30 14:44:45


Author: jared
Date: 2009-07-29 11:16:21 EDT (Wed, 29 Jul 2009)
New Revision: 55263
URL: http://svn.boost.org/trac/boost/changeset/55263

Log:
pinhole - fix memory leak and replacement process for actions
Text files modified:
   sandbox/pinhole/boost/pinhole/property_group.hpp | 12 +++++++++++-
   sandbox/pinhole/boost/pinhole/property_info.hpp | 6 ++++++
   2 files changed, 17 insertions(+), 1 deletions(-)

Modified: sandbox/pinhole/boost/pinhole/property_group.hpp
==============================================================================
--- sandbox/pinhole/boost/pinhole/property_group.hpp (original)
+++ sandbox/pinhole/boost/pinhole/property_group.hpp 2009-07-29 11:16:21 EDT (Wed, 29 Jul 2009)
@@ -705,7 +705,17 @@
             action_info->m_description = description;
             action_info->m_action = action;
             
- m_actions.insert( std::make_pair(name, action_info) );
+ action_collection::iterator previousInstance = m_actions.find(name);
+ if( m_actions.end() != previousInstance )
+ {
+ // Object already exists. Destroy existing instance and replace it.
+ delete (*previousInstance).second;
+ (*previousInstance).second = action_info;
+ }
+ else
+ {
+ m_actions.insert( std::make_pair(name, action_info) );
+ }
         }
 
         /**

Modified: sandbox/pinhole/boost/pinhole/property_info.hpp
==============================================================================
--- sandbox/pinhole/boost/pinhole/property_info.hpp (original)
+++ sandbox/pinhole/boost/pinhole/property_info.hpp 2009-07-29 11:16:21 EDT (Wed, 29 Jul 2009)
@@ -279,6 +279,9 @@
         virtual std::string get_as_string() const = 0;
         virtual std::wstring get_as_wstring() const = 0;
         virtual bool is_read_only() const = 0;
+
+ private:
+ property_info_base(const property_info_base&):m_type(typeid(void)){;} // this would be bad
     };
 
     template<typename T>
@@ -398,6 +401,9 @@
         {
             return( !setter );
         }
+
+ private:
+ property_info(const property_info<T>&) : property_info_base(typeid(void)){;} // this would be bad
     };
 }}}
 


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