diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index 58efb956..d819ce1f 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -268,8 +268,10 @@ class CAnimatedVariable { // methods void onAnimationEnd() { if (m_fEndCallback) { + // loading m_bRemoveEndAfterRan before calling the callback allows the callback to delete this animation safely if it is false. + auto removeEndCallback = m_bRemoveEndAfterRan; m_fEndCallback(this); - if (m_bRemoveEndAfterRan) + if (removeEndCallback) m_fEndCallback = nullptr; // reset } }