mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Fixed TrackEntry leak.
This commit is contained in:
parent
b0279701e4
commit
066fa3dcae
@ -50,6 +50,7 @@ typedef void (*spAnimationStateListener) (spAnimationState* state, int trackInde
|
||||
|
||||
typedef struct spTrackEntry spTrackEntry;
|
||||
struct spTrackEntry {
|
||||
spAnimationState* const state;
|
||||
spTrackEntry* next;
|
||||
spTrackEntry* previous;
|
||||
spAnimation* animation;
|
||||
|
||||
@ -115,11 +115,11 @@ typedef struct {
|
||||
spEvent** events;
|
||||
|
||||
spTrackEntry* (*createTrackEntry) (spAnimationState* self);
|
||||
void (*disposeTrackEntry) (spAnimationState* self, spTrackEntry* entry);
|
||||
void (*disposeTrackEntry) (spTrackEntry* entry);
|
||||
} _spAnimationState;
|
||||
|
||||
spTrackEntry* _spTrackEntry_create ();
|
||||
void _spTrackEntry_dispose (spTrackEntry* entry);
|
||||
spTrackEntry* _spTrackEntry_create (spAnimationState* self);
|
||||
void _spTrackEntry_dispose (spTrackEntry* self);
|
||||
|
||||
/**/
|
||||
|
||||
|
||||
@ -32,26 +32,27 @@
|
||||
#include <spine/extension.h>
|
||||
#include <string.h>
|
||||
|
||||
spTrackEntry* _spTrackEntry_create () {
|
||||
spTrackEntry* entry = NEW(spTrackEntry);
|
||||
entry->timeScale = 1;
|
||||
entry->lastTime = -1;
|
||||
entry->mix = 1;
|
||||
return entry;
|
||||
spTrackEntry* _spTrackEntry_create (spAnimationState* state) {
|
||||
spTrackEntry* self = NEW(spTrackEntry);
|
||||
CONST_CAST(spAnimationState*, self->state) = state;
|
||||
self->timeScale = 1;
|
||||
self->lastTime = -1;
|
||||
self->mix = 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
void _spTrackEntry_dispose (spTrackEntry* entry) {
|
||||
if (entry->previous) _spTrackEntry_dispose(entry->previous);
|
||||
FREE(entry);
|
||||
void _spTrackEntry_dispose (spTrackEntry* self) {
|
||||
if (self->previous) SUB_CAST(_spAnimationState, self->state)->disposeTrackEntry(self->previous);
|
||||
FREE(self);
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
spTrackEntry* _spAnimationState_createTrackEntry (spAnimationState* self) {
|
||||
return _spTrackEntry_create();
|
||||
return _spTrackEntry_create(self);
|
||||
}
|
||||
|
||||
void _spAnimationState_disposeTrackEntry (spAnimationState* self, spTrackEntry* entry) {
|
||||
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry) {
|
||||
_spTrackEntry_dispose(entry);
|
||||
}
|
||||
|
||||
@ -70,7 +71,7 @@ void _spAnimationState_disposeAllEntries (spAnimationState* self, spTrackEntry*
|
||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
||||
while (entry) {
|
||||
spTrackEntry* next = entry->next;
|
||||
internal->disposeTrackEntry(self, entry);
|
||||
internal->disposeTrackEntry(entry);
|
||||
entry = next;
|
||||
}
|
||||
}
|
||||
@ -147,7 +148,7 @@ void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
|
||||
|
||||
if (alpha >= 1) {
|
||||
alpha = 1;
|
||||
internal->disposeTrackEntry(self, current->previous);
|
||||
internal->disposeTrackEntry(current->previous);
|
||||
current->previous = 0;
|
||||
}
|
||||
spAnimation_mix(current->animation, skeleton, current->lastTime, time,
|
||||
@ -212,7 +213,7 @@ void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) {
|
||||
|
||||
self->tracks[trackIndex] = 0;
|
||||
|
||||
if (current->previous) internal->disposeTrackEntry(self, current->previous);
|
||||
if (current->previous) internal->disposeTrackEntry(current->previous);
|
||||
_spAnimationState_disposeAllEntries(self, current);
|
||||
}
|
||||
|
||||
@ -248,9 +249,9 @@ void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEnt
|
||||
} else
|
||||
entry->previous = current;
|
||||
} else
|
||||
internal->disposeTrackEntry(self, current);
|
||||
internal->disposeTrackEntry(current);
|
||||
|
||||
if (previous) internal->disposeTrackEntry(self, previous);
|
||||
if (previous) internal->disposeTrackEntry(previous);
|
||||
}
|
||||
|
||||
self->tracks[index] = entry;
|
||||
|
||||
@ -55,7 +55,7 @@ static _TrackEntryListeners* getListeners (spTrackEntry* entry) {
|
||||
return (_TrackEntryListeners*)entry->rendererObject;
|
||||
}
|
||||
|
||||
void disposeTrackEntry (spAnimationState* self, spTrackEntry* entry) {
|
||||
void disposeTrackEntry (spTrackEntry* entry) {
|
||||
if (entry->rendererObject) {
|
||||
_TrackEntryListeners* listeners = (_TrackEntryListeners*)entry->rendererObject;
|
||||
[listeners->startListener release];
|
||||
|
||||
@ -63,7 +63,7 @@ static _TrackEntryListeners* getListeners (spTrackEntry* entry) {
|
||||
return (_TrackEntryListeners*)entry->rendererObject;
|
||||
}
|
||||
|
||||
void disposeTrackEntry (spAnimationState* self, spTrackEntry* entry) {
|
||||
void disposeTrackEntry (spTrackEntry* entry) {
|
||||
if (entry->rendererObject) FREE(entry->rendererObject);
|
||||
_spTrackEntry_dispose(entry);
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ static _TrackEntryListeners* getListeners (spTrackEntry* entry) {
|
||||
return (_TrackEntryListeners*)entry->rendererObject;
|
||||
}
|
||||
|
||||
void disposeTrackEntry (spAnimationState* self, spTrackEntry* entry) {
|
||||
void disposeTrackEntry (spTrackEntry* entry) {
|
||||
if (entry->rendererObject) FREE(entry->rendererObject);
|
||||
_spTrackEntry_dispose(entry);
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ static _TrackEntryListeners* getListeners (spTrackEntry* entry) {
|
||||
return (_TrackEntryListeners*)entry->rendererObject;
|
||||
}
|
||||
|
||||
void disposeTrackEntry (spAnimationState* self, spTrackEntry* entry) {
|
||||
void disposeTrackEntry (spTrackEntry* entry) {
|
||||
if (entry->rendererObject) FREE(entry->rendererObject);
|
||||
_spTrackEntry_dispose(entry);
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
#include <SFML/Graphics/RenderStates.hpp>
|
||||
|
||||
#ifndef SPINE_MESH_VERTEX_COUNT_MAX
|
||||
#define SPINE_MESH_VERTEX_COUNT_MAX 200
|
||||
#define SPINE_MESH_VERTEX_COUNT_MAX 1000
|
||||
#endif
|
||||
|
||||
using namespace sf;
|
||||
@ -154,7 +154,7 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
|
||||
|
||||
} else if (attachment->type == ATTACHMENT_MESH) {
|
||||
MeshAttachment* mesh = (MeshAttachment*)attachment;
|
||||
if (mesh->uvsCount > SPINE_MESH_VERTEX_COUNT_MAX) continue;
|
||||
if (mesh->verticesCount > SPINE_MESH_VERTEX_COUNT_MAX) continue;
|
||||
texture = (Texture*)((AtlasRegion*)mesh->rendererObject)->page->rendererObject;
|
||||
MeshAttachment_computeWorldVertices(mesh, slot->skeleton->x, slot->skeleton->y, slot, worldVertices);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user