Browse Source

Clear the track before calling end on the listener.

NathanSweet 11 years ago
parent
commit
211f82fedd

+ 3 - 3
spine-as3/spine-as3/src/spine/animation/AnimationState.as

@@ -124,11 +124,11 @@ public class AnimationState {
 		if (trackIndex >= _tracks.length) return;
 		var current:TrackEntry = _tracks[trackIndex];
 		if (!current) return;
-		
-		if (current.onEnd != null) current.onEnd(trackIndex);
-		onEnd.invoke(trackIndex);
 
 		_tracks[trackIndex] = null;
+
+		if (current.onEnd != null) current.onEnd(trackIndex);
+		onEnd.invoke(trackIndex);
 	}
 	
 	private function expandToIndex (index:int) : TrackEntry {

+ 2 - 1
spine-c/src/spine/AnimationState.c

@@ -174,10 +174,11 @@ void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) {
 	current = self->tracks[trackIndex];
 	if (!current) return;
 
+	self->tracks[trackIndex] = 0;
+
 	if (current->listener) current->listener(self, trackIndex, ANIMATION_END, 0, 0);
 	if (self->listener) self->listener(self, trackIndex, ANIMATION_END, 0, 0);
 
-	self->tracks[trackIndex] = 0;
 	if (current->previous) _spTrackEntry_dispose(current->previous);
 	_spTrackEntry_disposeAll(current);
 }

+ 2 - 2
spine-csharp/src/AnimationState.cs

@@ -138,10 +138,10 @@ namespace Spine {
 			TrackEntry current = tracks[trackIndex];
 			if (current == null) return;
 
+			tracks[trackIndex] = null;
+
 			current.OnEnd(this, trackIndex);
 			if (End != null) End(this, trackIndex);
-
-			tracks[trackIndex] = null;
 		}
 
 		private TrackEntry ExpandToIndex (int index) {

+ 2 - 2
spine-js/spine.js

@@ -1038,10 +1038,10 @@ spine.AnimationState.prototype = {
 		var current = this.tracks[trackIndex];
 		if (!current) return;
 
+		this.tracks[trackIndex] = null;
+
 		if (current.onEnd != null) current.onEnd(trackIndex);
 		if (this.onEnd != null) this.onEnd(trackIndex);
-
-		this.tracks[trackIndex] = null;
 	},
 	_expandToIndex: function (index) {
 		if (index < this.tracks.length) return this.tracks[index];

+ 2 - 1
spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java

@@ -137,11 +137,12 @@ public class AnimationState {
 		TrackEntry current = tracks.get(trackIndex);
 		if (current == null) return;
 
+		tracks.set(trackIndex, null);
+
 		if (current.listener != null) current.listener.end(trackIndex);
 		for (int i = 0, n = listeners.size; i < n; i++)
 			listeners.get(i).end(trackIndex);
 
-		tracks.set(trackIndex, null);
 		freeAll(current);
 		if (current.previous != null) trackEntryPool.free(current.previous);
 	}

+ 3 - 3
spine-lua/AnimationState.lua

@@ -157,13 +157,13 @@ function AnimationState.new (data)
 		local current = self.tracks[trackIndex]
 		if not current then return end
 
-		if current.onEnd then current.onEnd(trackIndex) end
-		if self.onEnd then self.onEnd(trackIndex) end
-
 		self.tracks[trackIndex] = nil
 		if trackIndex == self.trackCount - 1 then
 			self.trackCount = self.trackCount - 1
 		end
+
+		if current.onEnd then current.onEnd(trackIndex) end
+		if self.onEnd then self.onEnd(trackIndex) end
 	end
 
 	function self:setAnimationByName (trackIndex, animationName, loop)