Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66475 - in trunk: boost/statechart libs/statechart/test
From: ahd6974-boostorg_at_[hidden]
Date: 2010-11-09 14:54:21


Author: andreas_huber69
Date: 2010-11-09 14:54:14 EST (Tue, 09 Nov 2010)
New Revision: 66475
URL: http://svn.boost.org/trac/boost/changeset/66475

Log:
Fixes #4817, correctly this time.
Text files modified:
   trunk/boost/statechart/state_machine.hpp | 19 ++++++++-----------
   trunk/libs/statechart/test/DeferralBug.cpp | 6 ++++++
   2 files changed, 14 insertions(+), 11 deletions(-)

Modified: trunk/boost/statechart/state_machine.hpp
==============================================================================
--- trunk/boost/statechart/state_machine.hpp (original)
+++ trunk/boost/statechart/state_machine.hpp 2010-11-09 14:54:14 EST (Tue, 09 Nov 2010)
@@ -275,9 +275,8 @@
       if ( send_event( evt ) == detail::do_defer_event )
       {
         // Before deferring, a reaction could post other events, which still
- // need to be processed. This is why we push the event at the front.
- eventQueue_.push_front( evt.intrusive_from_this() );
- eventQueueBegin_ = ++eventQueue_.begin();
+ // need to be processed. This is why we push the event at the beginning.
+ eventQueueBegin_ = ++eventQueue_.insert( eventQueueBegin_, evt.intrusive_from_this() );
       }
 
       process_queued_events();
@@ -908,22 +907,20 @@
     {
       while ( eventQueueBegin_ != eventQueue_.end() )
       {
- const event_base_ptr_type pCurrentEvent( *eventQueueBegin_ );
+ typename event_queue_type::iterator currentEventQueueBegin =
+ eventQueueBegin_++;
 
         try
         {
- if ( send_event( *pCurrentEvent ) == detail::do_defer_event )
+ if ( send_event( **currentEventQueueBegin ) !=
+ detail::do_defer_event )
           {
- ++eventQueueBegin_;
- }
- else
- {
- eventQueueBegin_ = eventQueue_.erase( eventQueueBegin_ );
+ eventQueue_.erase( currentEventQueueBegin );
           }
         }
         catch ( ... )
         {
- eventQueueBegin_ = eventQueue_.erase( eventQueueBegin_ );
+ eventQueue_.erase( currentEventQueueBegin );
           throw;
         }
       }

Modified: trunk/libs/statechart/test/DeferralBug.cpp
==============================================================================
--- trunk/libs/statechart/test/DeferralBug.cpp (original)
+++ trunk/libs/statechart/test/DeferralBug.cpp 2010-11-09 14:54:14 EST (Tue, 09 Nov 2010)
@@ -73,6 +73,12 @@
   machine.process_event( ev3to4_2() );
   machine.process_event( ev1to2() );
   BOOST_REQUIRE( machine.state_cast< const s4_1 * >() != 0 );
+ machine.initiate();
+ machine.process_event( ev3to4_1() );
+ machine.process_event( ev3to4_2() );
+ machine.process_event( ev1to2() );
+ machine.process_event( ev2to3() );
+ BOOST_REQUIRE( machine.state_cast< const s4_1 * >() != 0 );
 
   return 0;
 }


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