Animation timeline erase fix

master
Neirokan 2021-11-06 00:31:41 +03:00
parent f07f9a6638
commit dd307749be
1 changed files with 5 additions and 8 deletions

View File

@ -70,16 +70,12 @@ void Timeline::update() {
return; return;
} }
// TODO: sometimes I catch an exception here: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) for (auto iter = _instance->_animations.begin(); iter != _instance->_animations.end(); ) {
for (auto&[listName, animationList] : _instance->_animations) { if (iter->second.empty()) {
if (animationList.empty()) { _instance->_animations.erase(iter++);
/*
* TODO If you delete this line you will not catch an exception.
* Maybe something wrong with std::map::erase()
*/
_instance->_animations.erase(listName);
continue; continue;
} }
auto& animationList = iter->second;
auto it = animationList.begin(); auto it = animationList.begin();
// If it the front animation is 'a_wait()' we should wait until waiting time is over // If it the front animation is 'a_wait()' we should wait until waiting time is over
@ -98,6 +94,7 @@ void Timeline::update() {
it++; it++;
} }
} }
iter++;
} }
} }