Explorar o código

Fixed potential race condition

John Bolton %!s(int64=5) %!d(string=hai) anos
pai
achega
bb58d349cb
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      client/battle/CBattleInterface.cpp

+ 2 - 2
client/battle/CBattleInterface.cpp

@@ -49,10 +49,10 @@ CondSh<BattleAction *> CBattleInterface::givenCommand(nullptr);
 
 static void onAnimationFinished(const CStack *stack, std::weak_ptr<CCreatureAnimation> anim)
 {
-	if(anim.expired())
+	std::shared_ptr<CCreatureAnimation> animation = anim.lock();
+	if(!animation)
 		return;
 
-	std::shared_ptr<CCreatureAnimation> animation = anim.lock();
 	if (animation->isIdle())
 	{
 		const CCreature *creature = stack->getCreature();