From ff76fbe763ade84d97f3b50bc08276cdd0e7471e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 5 Nov 2022 13:37:29 +0000 Subject: [PATCH] prevent double-registering of avars --- src/helpers/AnimatedVariable.cpp | 5 ++++- src/helpers/AnimatedVariable.hpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp index c4a1713d..77707349 100644 --- a/src/helpers/AnimatedVariable.cpp +++ b/src/helpers/AnimatedVariable.cpp @@ -54,10 +54,13 @@ CAnimatedVariable::~CAnimatedVariable() { void CAnimatedVariable::unregister() { g_pAnimationManager->m_lAnimatedVariables.remove(this); + m_bIsRegistered = false; } void CAnimatedVariable::registerVar() { - g_pAnimationManager->m_lAnimatedVariables.push_back(this); + if (!m_bIsRegistered) + g_pAnimationManager->m_lAnimatedVariables.push_back(this); + m_bIsRegistered = true; } int CAnimatedVariable::getDurationLeftMs() { diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index 22c5da84..7b5a6895 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -200,6 +200,7 @@ private: SAnimationPropertyConfig* m_pConfig = nullptr; bool m_bDummy = true; + bool m_bIsRegistered = false; std::chrono::system_clock::time_point animationBegin;