When is it safe to destroy an animation instance
Posted: Tue Apr 10, 2012 17:55
In my code, I destroy an animation instance in the CEGUI::AnimationInstance::EventAnimationEnded handler. This works on my linux build but in my iPhone build the instance is destroyed before it is removed from the AnimationManager. At least, thats what I gather from the debugger... I get a memory error which halts the program in AnimationManager::stepInstances (on the iPhone simulator).
I've been looking at the code and it seems that the Animation Manager stores animation instances as a map Animation* -> AnimationInstance*. It appears that destroyAnimationInstance removes the element from the map. IIRC any time you erase something from a map any current read iterators become invalid. Perhaps this is incidentally not the case in the std::map implementation on my linux system, but is the case for the iPhone system (though they both appear to use red-black tree's for the implementation).
Anyway, whats the best way to destroy animation instances when they are finished?
I've been looking at the code and it seems that the Animation Manager stores animation instances as a map Animation* -> AnimationInstance*. It appears that destroyAnimationInstance removes the element from the map. IIRC any time you erase something from a map any current read iterators become invalid. Perhaps this is incidentally not the case in the std::map implementation on my linux system, but is the case for the iPhone system (though they both appear to use red-black tree's for the implementation).
Anyway, whats the best way to destroy animation instances when they are finished?