@@ -36,6 +36,7 @@ cc.HashElement = function () {
3636 this . actionIndex = 0 ;
3737 this . currentAction = null ; //CCAction
3838 this . paused = false ;
39+ this . lock = false ;
3940} ;
4041
4142/**
@@ -84,6 +85,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
8485 element . currentAction = null ;
8586 element . paused = false ;
8687 element . target = null ;
88+ element . lock = false ;
8789 this . _elementPool . push ( element ) ;
8890 } ,
8991
@@ -303,7 +305,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
303305
304306 _deleteHashElement :function ( element ) {
305307 var ret = false ;
306- if ( element ) {
308+ if ( element && ! element . lock ) {
307309 if ( this . _hashTargets [ element . target . __instanceId ] ) {
308310 delete this . _hashTargets [ element . target . __instanceId ] ;
309311 var targets = this . _arrayTargets ;
@@ -329,6 +331,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
329331 this . _currentTarget = locTargets [ elt ] ;
330332 locCurrTarget = this . _currentTarget ;
331333 if ( ! locCurrTarget . paused && locCurrTarget . actions ) {
334+ locCurrTarget . lock = true ;
332335 // The 'actions' CCMutableArray may change while inside this loop.
333336 for ( locCurrTarget . actionIndex = 0 ; locCurrTarget . actionIndex < locCurrTarget . actions . length ; locCurrTarget . actionIndex ++ ) {
334337 locCurrTarget . currentAction = locCurrTarget . actions [ locCurrTarget . actionIndex ] ;
@@ -338,16 +341,16 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
338341 //use for speed
339342 locCurrTarget . currentAction . step ( dt * ( locCurrTarget . currentAction . _speedMethod ? locCurrTarget . currentAction . _speed : 1 ) ) ;
340343
341- if ( locCurrTarget . currentAction . isDone ( ) ) {
344+ if ( locCurrTarget . currentAction && locCurrTarget . currentAction . isDone ( ) ) {
342345 locCurrTarget . currentAction . stop ( ) ;
343346 var action = locCurrTarget . currentAction ;
344- // Make currentAction nil to prevent removeAction from salvaging it.
345347 locCurrTarget . currentAction = null ;
346348 this . removeAction ( action ) ;
347349 }
348350
349351 locCurrTarget . currentAction = null ;
350352 }
353+ locCurrTarget . lock = false ;
351354 }
352355 // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
353356 if ( locCurrTarget . actions . length === 0 ) {
0 commit comments