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