Author: mordante
Date: Sun Oct 23 19:48:59 2011
New Revision: 51592

URL: http://svn.gna.org/viewcvs/wesnoth?rev=51592&view=rev
Log:
Avoid copying a singular iterator.

Gabba, tschitz please review whether the code is correct. It fixes some
abortions of Wesnoth when using the gcc debug containers due to
undefined behaviour.

Modified:
    trunk/src/whiteboard/manager.cpp

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=51592&r1=51591&r2=51592&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Sun Oct 23 19:48:59 2011
@@ -240,6 +240,10 @@
                        return true;
        } // end planned unit map scope
 
+       if(viewer_actions()->empty()) {
+               return true;
+       }
+
        //Look for planned recruits that depend on this leader
        foreach(action_const_ptr action, *viewer_actions())
        {
@@ -268,8 +272,9 @@
 void manager::on_finish_side_turn(int side)
 {
        wait_for_side_init_ = true;
-       if(side == viewer_side())
+       if(side == viewer_side() && !viewer_actions()->empty()) {
                viewer_actions()->synced_turn_shift();
+       }
        highlighter_.reset();
        erase_temp_move();
        LOG_WB << "on_finish_side_turn()\n";
@@ -343,6 +348,10 @@
 
 bool manager::current_side_has_actions()
 {
+       if(current_side_actions()->empty()) {
+               return false;
+       }
+
        side_actions::range_t range = current_side_actions()->iter_turn(0);
        return range.first != range.second; //non-empty range
 }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to