(fix for bug #18879)
There was an implicit conversion config::attribute_value to int with
default 0. Strangely, this sometimes went well with my MinGw built and
also does for some time in Espreon's backtrace, but MSVC crashes early
where the resulting out-of-bounds problem occurs (actions.cpp:2366)
The only thing this commit did was mess around with dangled pointer
access timings instead of solving the original UB that it was supposed
to fix (see bug #18495). There's no problem with accessing theme UI
buttons before they are initialized since they will be NULL and the
replay controller already made sure to not do silly crap with NULL
pointers (except for the case spotted in 2011-11-04T04:27:26Z!shadowm@wesnoth.org).
(IRC users: please read the entire commit message instead of relyingon CIA.)
2011-02-07T21:43:12Z!b.waresiak@gmail.com introduced some code, purportedly intended to fix bug
#16237, which relied on game_display/display never destroying buttons
returned by the find_button() method. Unfortunately, many code paths
calling game_display/display::draw() cause them to be destroyed and
recreated, resulting in UB from code that still keeps the old pointers
around and doesn't refresh them before use.
This commit removes the replay_controller::replay_buttons_wrapper
class and reintegrates its code into the replay_controller class to
remove one unrequired abstraction layer, without entirely reverting
2011-02-07T21:43:12Z!b.waresiak@gmail.com. It also makes sure pointers aren't kept for longer than
necessary, disposing of them after use and calling
game_display/display::find_button() every single time a button has to
be accessed. This shouldn't result in noticeable runtime overhead
increase as the buttons are stored in a vector which is rarely very
large (I have yet to see a Wesnoth GUI theme that has more than ten
buttons).
As a side-effect of my changes, however, a glitch on the Skip
Animations checkbox background has appeared. Considering I don't touch
that button at all, it's possible there's a different cause for it
that was concealed by the replay buttons' triggered UB.
I don't think this side-effect is more important at this point than the
original bug, and I or someone else can investigate it later.
NOTE: If someone has a reasonable argument for this commit being
reverted before 1.9.10, feel free to discuss that with me.