Author: mordante
Date: Tue Oct 25 21:31:45 2011
New Revision: 51639
URL: http://svn.gna.org/viewcvs/wesnoth?rev=51639&view=rev
Log:
Avoid copying a singular iterator.
Found a better way to avoid copying singular iterators.
Gabba, tschmitz please review the code and if it's correct it should be
save to revert r51592.
Modified:
trunk/changelog
trunk/src/whiteboard/side_actions.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=51639&r1=51638&r2=51639&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Oct 25 21:31:45 2011
@@ -86,6 +86,7 @@
* Fix gold carryover if loading a save created in linger mode (bug #16111)
* Fixed: Compilation with boost 1.47 (bug #18399's patch).
* Fixed: Compilation with the clang 2.9 compiler (bug #18399's patch).
+ * Fixed: Avoid copying of singular iterators in the whiteboard code.
Version 1.9.9:
* AI:
Modified: trunk/src/whiteboard/side_actions.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/side_actions.hpp?rev=51639&r1=51638&r2=51639&view=diff
==============================================================================
--- trunk/src/whiteboard/side_actions.hpp (original)
+++ trunk/src/whiteboard/side_actions.hpp Tue Oct 25 21:31:45 2011
@@ -309,6 +309,19 @@
, contents_(that.base().contents_)
{}
+ /**
+ * Copy constructor.
+ *
+ * If the contents_ is NULL the iterator is singular. Copying singular
+ * iterators is UB, so avoid it.
+ */
+ iterator(const iterator& that)
+ : base_(that.contents_ ? that.base_ : base_t())
+ , turn_num_(that.contents_ ? that.turn_num_ : 0)
+ , contents_(that.contents_)
+ {
+ }
+
action_ptr& operator*() const {return *base_;}
action_ptr* operator->() const {return base_.operator->();}
this_t& operator++()
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits