mail[Wesnoth-commits] r44197 - in /trunk/src/whiteboard: side_actions.cpp side_actions.hpp validate_visitor.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by gabrielmorin on July 15, 2010 - 22:49:
Author: gabba
Date: Thu Jul 15 22:49:05 2010
New Revision: 44197

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44197&view=rev
Log:
Whiteboard: hopefully definitive fixes for the crash on action removal. 
Validate actions recursively until no more remain to delete (may be overkill)

Modified:
    trunk/src/whiteboard/side_actions.cpp
    trunk/src/whiteboard/side_actions.hpp
    trunk/src/whiteboard/validate_visitor.cpp

Modified: trunk/src/whiteboard/side_actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/side_actions.cpp?rev=44197&r1=44196&r2=44197&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.cpp (original)
+++ trunk/src/whiteboard/side_actions.cpp Thu Jul 15 22:49:05 2010
@@ -214,7 +214,7 @@
        return valid_position;
 }
 
-side_actions::iterator side_actions::remove_action(side_actions::iterator 
position)
+side_actions::iterator side_actions::remove_action(side_actions::iterator 
position, bool validate_after_delete)
 {
        if (resources::whiteboard->has_planned_unit_map())
        {
@@ -227,8 +227,10 @@
        if (!actions_.empty() && validate_iterator(position))
        {
                actions_.erase(position);
-               //FIXME: causes infinite recursive call
-               validate_actions();
+               if (validate_after_delete)
+               {
+                       validate_actions();
+               }
        }
        return begin() + distance;
 }

Modified: trunk/src/whiteboard/side_actions.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/side_actions.hpp?rev=44197&r1=44196&r2=44197&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.hpp (original)
+++ trunk/src/whiteboard/side_actions.hpp Thu Jul 15 22:49:05 2010
@@ -128,7 +128,7 @@
         * Deletes the action at the specified position.
         * @return The position of the element after the one deleted, or 
end() if the queue is empty.
         */
-       iterator remove_action(iterator position);
+       iterator remove_action(iterator position, bool validate_after_delete 
= true);
 
        /**
         * @param action The action whose position you're looking for

Modified: trunk/src/whiteboard/validate_visitor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/validate_visitor.cpp?rev=44197&r1=44196&r2=44197&view=diff
==============================================================================
--- trunk/src/whiteboard/validate_visitor.cpp (original)
+++ trunk/src/whiteboard/validate_visitor.cpp Thu Jul 15 22:49:05 2010
@@ -56,9 +56,14 @@
                action->accept(*this);
        }
 
-       foreach(action_ptr action, actions_to_erase_)
+       if (!actions_to_erase_.empty())
        {
-               
side_actions_->remove_action(side_actions_->get_position_of(action));
+               foreach(action_ptr action, actions_to_erase_)
+               {
+                       
side_actions_->remove_action(side_actions_->get_position_of(action), false);
+               }
+               actions_to_erase_.clear();
+               validate_actions();
        }
 }
 




Related Messages


Powered by MHonArc, Updated Thu Jul 15 23:00:11 2010