Bug in CCBAnimationManager (and solution!)

Hi,

If you try to play again an animation once it is finished (on the completedAnimationSequenceNamed delegate based on CCBAnimationManagerDelegate), cocos throws an exception. To avoid that, the CCBAnimationManager::sequenceCompleted method should be modified to this:

void CCBAnimationManager::sequenceCompleted()
{
const char* seqname = mRunningSequence~~>getName;
int nextSeqId = mRunningSequence~~>getChainedSequenceId();
mRunningSequence = NULL;

if (nextSeqId != 1)
{
runAnimations;
}
if
{
mDelegate
>completedAnimationSequenceNamed(seqname);
}
}

I’m not sure if this change has other implications… but it shouldn’t

thanks.

Could you please describe how to reproduce it?
Can i reproduce it by using CocosBuilderTest?

yes sorry:

1-play an animation by calling animationManager~~>runAnimations; .
2-when the animation ends, the completedAnimationSequenceNamed delegate is fired.
3-try to execute the animation again from the delegate animationManager~~>runAnimations(“ArmPigForeground”); will cause an error

Jesús

I also have added this code to the setAnimatedProperty, in order to support visible ON/OF animation properties.

else if (strcmp(pPropName, “visible”) == 0)
{
bool isVisible = ((CCBValue*)pValue)>getBoolValue;
pNode)
>setVisible(isVisible);
}

Minggo Zhang wrote:

Could you please describe how to reproduce it?
Can i reproduce it by using CocosBuilderTest?

I got this issue too.
According to the source, after you call CCBAnimationManager::runAnimations in CCBAnimationManagerDelegate::completedAnimationSequenceNamed callback, the mRunningSequence will be set to NULL.
So when the next CCBAnimationManagerDelegate::completedAnimationSequenceNamed is fired, you got crash by mRunningSequence->getName();

The thread author’s solution is almost there.
I think put the delegate call back before the nextSeqId check is better.
I’ll come up with a pull request in github latter.

mmm Dai, isn’t this fixed into the last available build?

Jesus Bosch wrote:

mmm Dai, isn’t this fixed into the last available build?

I don’t think so. I’ve post a pull request:

well done, thanks