for (std::vector::iterator iter = animations.begin (); iter != animations.end (); ) { if (animations[iter].complete && animations[iter].opacity <= 0) iter = animations.erase(iter); else iter++; if (animations.empty ()) { cScreen->preparePaintSetEnabled (this, false); cScreen->donePaintSetEnabled (this, false); animations.clear (); animating = false; } }