From 0436f1ff6d64f6864c89fa7aa2f8dc7129550179 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 12 Sep 2018 14:54:08 +0100 Subject: [PATCH] If you flagged a Tween as `paused` in its config, never started it, and then called `Tween.stop` it wouldn't ever be removed from the `_pending` array. It's now moved to the Tween Manager's destroy list, ready for removal on the next frame. Fix #4023 --- CHANGELOG.md | 3 ++- src/tweens/TweenManager.js | 14 +++++++++++++- src/tweens/tween/Tween.js | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a3345b70..21874cb8c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,12 +63,13 @@ This change has been introduced for `pointerdown`, `pointerup`, `pointermove`, ` * TileSprite.setTileScale would set the tile position by mistake, instead of the scale. Using the properties directly worked, but the method was incorrect (thanks @alexeymolchan) * Calling `Text.setStyle` would make the Text vanish if you didn't provide a `resolution` property in the style configuration object. Calling `setStyle` now only changes the properties given in the object, leaving any previously changed properties as-is. Fix #4011 (thanks @okcompewter) * In Matter.js if a body had its debug `render.visible` property set to `false` it wouldn't then render any other debug body beyond it. Now it will just skip bodies with hidden debug graphics (thanks @jf908) +* If you flagged a Tween as `paused` in its config, never started it, and then called `Tween.stop` it wouldn't ever be removed from the `_pending` array. It's now moved to the Tween Manager's destroy list, ready for removal on the next frame. Fix #4023 (thanks @goldfire) ### Examples, Documentation and TypeScript My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs: - +@johanlindfors @Arthur3DLHC ## Version 3.12.0 - Silica - 4th September 2018 diff --git a/src/tweens/TweenManager.js b/src/tweens/TweenManager.js index 32ec7feaf9..1971b0b11e 100644 --- a/src/tweens/TweenManager.js +++ b/src/tweens/TweenManager.js @@ -275,6 +275,7 @@ var TweenManager = new Class({ var list = this._destroy; var active = this._active; + var pending = this._pending; var i; var tween; @@ -286,7 +287,18 @@ var TweenManager = new Class({ // Remove from the 'active' array var idx = active.indexOf(tween); - if (idx !== -1) + if (idx === -1) + { + // Not in the active array, is it in pending instead? + idx = pending.indexOf(tween); + + if (idx > -1) + { + tween.state = TWEEN_CONST.REMOVED; + pending.splice(idx, 1); + } + } + else { tween.state = TWEEN_CONST.REMOVED; active.splice(idx, 1); diff --git a/src/tweens/tween/Tween.js b/src/tweens/tween/Tween.js index 92845ac41a..4ee2277f77 100644 --- a/src/tweens/tween/Tween.js +++ b/src/tweens/tween/Tween.js @@ -899,6 +899,12 @@ var Tween = new Class({ if (this.state !== TWEEN_CONST.REMOVED) { + if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD) + { + this.parent._destroy.push(this); + this.parent._toProcess++; + } + this.state = TWEEN_CONST.PENDING_REMOVE; } },