Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61048 - in trunk: boost/statechart libs/statechart/doc
From: ahd6974-boostorg_at_[hidden]
Date: 2010-04-04 14:45:45


Author: andreas_huber69
Date: 2010-04-04 14:45:45 EDT (Sun, 04 Apr 2010)
New Revision: 61048
URL: http://svn.boost.org/trac/boost/changeset/61048

Log:
Fixes #3963. post_event() is now protected and forwards to post_event_impl(), which unfortunately must remain public. So, client code can still abuse the class by calling post_event_impl(), but the abuse should now be more obvious. I considered adding an assert to post_event_impl(), so that unauthorized calls from the outside could at least be detected at runtime, but it turned out that an assert requires more additional machinery than expected, which is why it was not implemented.

Thanks for the report!
Text files modified:
   trunk/boost/statechart/simple_state.hpp | 4 ++--
   trunk/boost/statechart/state_machine.hpp | 26 ++++++++++++++++++--------
   trunk/libs/statechart/doc/acknowledgments.html | 19 ++++++++++---------
   trunk/libs/statechart/doc/future_and_history.html | 8 ++++++--
   4 files changed, 36 insertions(+), 21 deletions(-)

Modified: trunk/boost/statechart/simple_state.hpp
==============================================================================
--- trunk/boost/statechart/simple_state.hpp (original)
+++ trunk/boost/statechart/simple_state.hpp 2010-04-04 14:45:45 EDT (Sun, 04 Apr 2010)
@@ -283,12 +283,12 @@
 
     void post_event( const event_base_ptr_type & pEvent )
     {
- outermost_context_base().post_event( pEvent );
+ outermost_context_base().post_event_impl( pEvent );
     }
 
     void post_event( const event_base & evt )
     {
- outermost_context_base().post_event( evt );
+ outermost_context_base().post_event_impl( evt );
     }
 
     result discard_event()

Modified: trunk/boost/statechart/state_machine.hpp
==============================================================================
--- trunk/boost/statechart/state_machine.hpp (original)
+++ trunk/boost/statechart/state_machine.hpp 2010-04-04 14:45:45 EDT (Sun, 04 Apr 2010)
@@ -423,22 +423,21 @@
       terminate_impl( false );
     }
 
- public:
- //////////////////////////////////////////////////////////////////////////
- // The following declarations should be protected.
- // They are only public because many compilers lack template friends.
- //////////////////////////////////////////////////////////////////////////
     void post_event( const event_base_ptr_type & pEvent )
     {
- BOOST_ASSERT( get_pointer( pEvent ) != 0 );
- eventQueue_.push_back( pEvent );
+ post_event_impl( pEvent );
     }
 
     void post_event( const event_base & evt )
     {
- post_event( evt.intrusive_from_this() );
+ post_event_impl( evt );
     }
 
+ public:
+ //////////////////////////////////////////////////////////////////////////
+ // The following declarations should be protected.
+ // They are only public because many compilers lack template friends.
+ //////////////////////////////////////////////////////////////////////////
     template<
       class HistoryContext,
       detail::orthogonal_position_type orthogonalPosition >
@@ -515,6 +514,17 @@
     typedef mpl::bool_< false > deep_history;
     typedef mpl::bool_< false > inherited_deep_history;
 
+ void post_event_impl( const event_base_ptr_type & pEvent )
+ {
+ BOOST_ASSERT( get_pointer( pEvent ) != 0 );
+ eventQueue_.push_back( pEvent );
+ }
+
+ void post_event_impl( const event_base & evt )
+ {
+ post_event_impl( evt.intrusive_from_this() );
+ }
+
     detail::reaction_result react_impl(
       const event_base_type &,
       typename rtti_policy_type::id_type )

Modified: trunk/libs/statechart/doc/acknowledgments.html
==============================================================================
--- trunk/libs/statechart/doc/acknowledgments.html (original)
+++ trunk/libs/statechart/doc/acknowledgments.html 2010-04-04 14:45:45 EDT (Sun, 04 Apr 2010)
@@ -84,15 +84,16 @@
 
   <p>Thanks for feedback and/or encouragement go to:</p>
 
- <p>Bardur Arantsson, Robert Bell, Bohdan, Wayne Chao, Topher Cooper,
- Philippe David, Peter Dimov, Reece Dunn, Grant Erickson, John Fuller,
- Jeff Garland, Eugene Gladyshev, David A. Greene, Douglas Gregor, Gustavo
- Guerra, Aleksey Gurtovoy, Federico J. Fern&aacute;ndez, Iain K. Hanson,
- Steve Hawkes, David B. Held, J&uuml;rgen Hunold, Sean Kelly, Oliver
- Kowalke, Thomas Mathys, Simon Meiklejohn, Jiang Miao, Johan Nilsson,
- Matthieu Paindavoine, Chris Paulse, Igor R, Yuval Ronen, Chris Russell,
- Bryan Silverthorn, Rob Stewart, Kwee Heong Tan, Marcin Tustin, Vincent N.
- Virgilio, Gang Wang, Steven Watanabe, Richard Webb and Scott Woods.</p>
+ <p>Bardur Arantsson, Arne Babnik, Robert Bell, Bohdan, Wayne Chao,
+ Topher Cooper, Philippe David, Peter Dimov, Reece Dunn, Grant Erickson,
+ John Fuller, Jeff Garland, Eugene Gladyshev, David A. Greene, Douglas
+ Gregor, Gustavo Guerra, Aleksey Gurtovoy, Federico J. Fern&aacute;ndez,
+ Iain K. Hanson, Steve Hawkes, David B. Held, J&uuml;rgen Hunold, Sean
+ Kelly, Oliver Kowalke, Thomas Mathys, Simon Meiklejohn, Jiang Miao, Johan
+ Nilsson, Matthieu Paindavoine, Chris Paulse, Igor R, Yuval Ronen, Chris
+ Russell, Bryan Silverthorn, Rob Stewart, Kwee Heong Tan, Marcin Tustin,
+ Vincent N. Virgilio, Gang Wang, Steven Watanabe, Richard Webb and Scott
+ Woods.</p>
   <hr>
 
   <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=

Modified: trunk/libs/statechart/doc/future_and_history.html
==============================================================================
--- trunk/libs/statechart/doc/future_and_history.html (original)
+++ trunk/libs/statechart/doc/future_and_history.html 2010-04-04 14:45:45 EDT (Sun, 04 Apr 2010)
@@ -131,9 +131,13 @@
   <ul>
     <li>Generalized the context() functions so that they can also return a
     reference to any public base type of a context. This also makes
- transition&lt;&gt; &amp; in_state_reaction&lt;&gt; more general, reported by Igor R</li>
+ transition&lt;&gt; &amp; in_state_reaction&lt;&gt; more general, reported
+ by Igor R</li>
     <li>Added triggering_event()</li>
- <li>Fixed Bug #3329 (shadow variable warnings), reported by Grant Erickson</li>
+ <li>Fixed Bug #3329 (shadow variable warnings), reported by Grant
+ Erickson</li>
+ <li>Fixed Bug #3963 (state_machine&lt;&gt;::post_event() should be
+ protected), reported by Arne Babnik</li>
   </ul>
 
   <p>1.40.0</p>


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