[c][cpp] Fix AnimationState::clearNext()

This commit is contained in:
badlogic 2021-06-21 17:45:34 +02:00
parent bd10d050d2
commit 30702a3bff
8 changed files with 16 additions and 30 deletions

1
.gitignore vendored
View File

@ -143,3 +143,4 @@ spine-ue4/SpineUE4.VC.VC.opendb
.gradle/
*.iml
*/out/
cmake-build-debug-visual-studio

View File

@ -33,5 +33,5 @@ if((${SPINE_COCOS2D_X}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-cocos2dx"
add_subdirectory(spine-cocos2dx)
endif()
add_subdirectory(spine-c/spine-c-unit-tests)
# add_subdirectory(spine-c/spine-c-unit-tests)
add_subdirectory(spine-cpp/spine-cpp-unit-tests)

View File

@ -3,7 +3,9 @@ project(spine_unit_test)
set(CMAKE_INSTALL_PREFIX "./")
set(CMAKE_VERBOSE_MAKEFILE ON)
if(MSVC)
set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-rtti -DKANJI_MEMTRACE -DUSE_CPP11_MUTEX")
endif()
#########################################################

View File

@ -143,6 +143,8 @@ SP_API float spTrackEntry_getAnimationTime(spTrackEntry *entry);
SP_API float spTrackEntry_getTrackComplete(spTrackEntry *entry);
SP_API void spAnimationState_clearNext(spAnimationState *self, spTrackEntry *entry);
/** Use this to dispose static memory before your app exits to appease your memory leak detector*/
SP_API void spAnimationState_disposeStatics();

View File

@ -78,8 +78,6 @@ spTrackEntry *
_spAnimationState_trackEntry(spAnimationState *self, int trackIndex, spAnimation *animation, int /*boolean*/ loop,
spTrackEntry *last);
void _spAnimationState_disposeNext(spAnimationState *self, spTrackEntry *entry);
void _spAnimationState_animationsChanged(spAnimationState *self);
float *_spAnimationState_resizeTimelinesRotation(spTrackEntry *entry, int newSize);
@ -321,7 +319,7 @@ void spAnimationState_update(spAnimationState *self, float delta) {
if (current->trackLast >= current->trackEnd && current->mixingFrom == 0) {
self->tracks[i] = 0;
_spEventQueue_end(internal->queue, current);
_spAnimationState_disposeNext(self, current);
spAnimationState_clearNext(self, current);
continue;
}
}
@ -742,10 +740,6 @@ void _spAnimationState_queueEvents(spAnimationState *self, spTrackEntry *entry,
}
}
void spAnimationState_clearNext(spTrackEntry *entry) {
_spAnimationState_disposeTrackEntry(entry);
}
void spAnimationState_clearTracks(spAnimationState *self) {
_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
int i, n, oldDrainDisabled;
@ -770,7 +764,7 @@ void spAnimationState_clearTrack(spAnimationState *self, int trackIndex) {
_spEventQueue_end(internal->queue, current);
_spAnimationState_disposeNext(self, current);
spAnimationState_clearNext(self, current);
entry = current;
while (1) {
@ -827,11 +821,11 @@ spAnimationState_setAnimation(spAnimationState *self, int trackIndex, spAnimatio
self->tracks[trackIndex] = current->mixingFrom;
_spEventQueue_interrupt(internal->queue, current);
_spEventQueue_end(internal->queue, current);
_spAnimationState_disposeNext(self, current);
spAnimationState_clearNext(self, current);
current = current->mixingFrom;
interrupt = 0;
} else
_spAnimationState_disposeNext(self, current);
spAnimationState_clearNext(self, current);
}
entry = _spAnimationState_trackEntry(self, trackIndex, animation, loop, current);
_spAnimationState_setCurrent(self, trackIndex, entry, interrupt);
@ -957,7 +951,7 @@ _spAnimationState_trackEntry(spAnimationState *self, int trackIndex, spAnimation
return entry;
}
void _spAnimationState_disposeNext(spAnimationState *self, spTrackEntry *entry) {
void spAnimationState_clearNext(spAnimationState *self, spTrackEntry *entry) {
_spAnimationState *internal = SUB_CAST(_spAnimationState, self);
spTrackEntry *next = entry->next;
while (next) {

View File

@ -79,12 +79,6 @@ void spKeyValueArray_addAllValues(spKeyValueArray *self, spKeyValue *values, int
for (; i < n; i++) { spKeyValueArray_add(self, values[i]); }
}
void spKeyValueArray_removeAt(spKeyValueArray *self, int index) {
self->size--;
__builtin___memmove_chk(self->items + index, self->items + index + 1, sizeof(spKeyValue) * (self->size - index),
__builtin_object_size(self->items + index, 0));
}
int spKeyValueArray_contains(spKeyValueArray *self, spKeyValue value) {
spKeyValue *items = self->items;
int i, n;

View File

@ -480,9 +480,6 @@ namespace spine {
/// @param last May be NULL.
TrackEntry *newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last);
/// Dispose all track entries queued after the given TrackEntry.
void disposeNext(TrackEntry *entry);
void animationsChanged();
void computeHold(TrackEntry *entry);

View File

@ -383,7 +383,7 @@ void AnimationState::update(float delta) {
_tracks[i] = NULL;
_queue->end(currentP);
disposeNext(currentP);
clearNext(currentP);
continue;
}
@ -513,7 +513,7 @@ void AnimationState::clearTrack(size_t trackIndex) {
_queue->end(current);
disposeNext(current);
clearNext(current);
TrackEntry *entry = current;
while (true) {
@ -548,11 +548,11 @@ TrackEntry *AnimationState::setAnimation(size_t trackIndex, Animation *animation
_tracks[trackIndex] = current->_mixingFrom;
_queue->interrupt(current);
_queue->end(current);
disposeNext(current);
clearNext(current);
current = current->_mixingFrom;
interrupt = false;
} else {
disposeNext(current);
clearNext(current);
}
}
@ -911,10 +911,6 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
}
}
void AnimationState::clearNext(TrackEntry *entry) {
disposeNext(entry->_next);
}
void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrupt) {
TrackEntry *from = expandToIndex(index);
_tracks[index] = current;
@ -979,7 +975,7 @@ TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animatio
return entryP;
}
void AnimationState::disposeNext(TrackEntry *entry) {
void AnimationState::clearNext(TrackEntry *entry) {
TrackEntry *next = entry->_next;
while (next != NULL) {
_queue->dispose(next);