I am destroying windows while CEGUI is firing update events. This was resulting in a crash from vector out of bounds in:
Code: Select all
void Window::update(float elapsed);
The cause is that the size of the vector is being cached, therefore if the size is reduced there will be a crash.
Code: Select all
size_t vectSize = getChildCount();
for (size_t i = 0; i < vectSize; ++i)
d_children[i]->update(elapsed);
The solution to this is to not cache the variable and call getChildCount() from within the for loop declaration as follows.
Code: Select all
for (size_t i = 0; i < getChildCount(); ++i)
d_children[i]->update(elapsed);
No more crashes, and with the inline any suitable compiler option selected should be a minimal performance overhead.
ER.