This is transferred from EsotericSoftware/spine-runtimes2898
I used 4.2 spine-c for my project, and I'm migrating it to spine-cpp based spine-c which is introduced in spine 4.3 beta
while I'm testing it I found that spine-c and spine-cpp has different lifecycle event when animationState is disposed
this is original spine-c in 4.2
EsotericSoftware/spine-runtimesblob/4.2/spine-c/spine-c/src/spine/AnimationState.c#L266-L276
void spAnimationState_dispose(spAnimationState *self) {
int i;
_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
for (i = 0; i < self->tracksCount; i++)
_spAnimationState_disposeTrackEntries(self, self->tracks[i]);
FREE(self->tracks);
_spEventQueue_free(internal->queue);
FREE(internal->events);
FREE(internal->propertyIDs);
FREE(internal);
}
and this is the spine-cpp in 4.3 beta
void spine_animation_state_dispose(spine_animation_state self) {
delete (AnimationState *) self;
}
AnimationState::~AnimationState() {
for (size_t i = 0; i < _tracks.size(); i++) {
TrackEntry *entry = _tracks[i];
if (entry) {
TrackEntry *from = entry->_mixingFrom;
while (from) {
TrackEntry *curr = from;
from = curr->_mixingFrom;
delete curr;
}
TrackEntry *next = entry->_next;
while (next) {
TrackEntry *curr = next;
next = curr->_next;
delete curr;
}
delete entry;
}
}
delete _queue;
}
TrackEntry::~TrackEntry() {
}
So in spine-cpp version pending TrackEntry does not receives "dispose" event, when spine data structure and animationState falls to dispose.
So my ported code causes memory leak since no "dispose" event is called to clean up custom listener context.
I understand that js, ts, csharp, java which has "gc" for managed objects it is hard to tell "dispose" event for this case.
I just want to know, which is the intended behavior? trackentry should pass through dispose event when animationState is disposed? or just deleted unconditionaly?