From 836207468177a171893fe07e77b160ece1500814 Mon Sep 17 00:00:00 2001 From: badlogic Date: Tue, 19 Nov 2019 15:28:32 +0100 Subject: [PATCH] [ue4] Null check for track entry at specific index. Closes #1548. --- .../Private/SpineSkeletonAnimationComponent.cpp | 14 +++++++------- .../Source/SpinePlugin/Private/SpineWidget.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp index 21f91fbbf..d996c33a7 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp @@ -40,8 +40,8 @@ void UTrackEntry::SetTrackEntry(TrackEntry* trackEntry) { void callback(AnimationState* state, spine::EventType type, TrackEntry* entry, Event* event) { USpineSkeletonAnimationComponent* component = (USpineSkeletonAnimationComponent*)state->getRendererObject(); - - if (entry->getRendererObject()) { + + if (entry->getRendererObject()) { UTrackEntry* uEntry = (UTrackEntry*)entry->getRendererObject(); if (type == EventType_Start) { component->AnimationStart.Broadcast(uEntry); @@ -70,7 +70,7 @@ void callback(AnimationState* state, spine::EventType type, TrackEntry* entry, E uEntry->SetTrackEntry(nullptr); component->GCTrackEntry(uEntry); } - } + } } USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent () { @@ -154,7 +154,7 @@ void USpineSkeletonAnimationComponent::CheckState () { } } -void USpineSkeletonAnimationComponent::DisposeState () { +void USpineSkeletonAnimationComponent::DisposeState () { if (state) { delete state; state = nullptr; @@ -225,14 +225,14 @@ UTrackEntry* USpineSkeletonAnimationComponent::SetAnimation (int trackIndex, FSt trackEntries.Add(uEntry); return uEntry; } else return NewObject(); - + } UTrackEntry* USpineSkeletonAnimationComponent::AddAnimation (int trackIndex, FString animationName, bool loop, float delay) { CheckState(); if (state && skeleton->getData()->findAnimation(TCHAR_TO_UTF8(*animationName))) { state->disableQueue(); - TrackEntry* entry = state->addAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop, delay); + TrackEntry* entry = state->addAnimation(trackIndex, TCHAR_TO_UTF8(*animationName), loop, delay); state->enableQueue(); UTrackEntry* uEntry = NewObject(); uEntry->SetTrackEntry(entry); @@ -265,7 +265,7 @@ UTrackEntry* USpineSkeletonAnimationComponent::AddEmptyAnimation (int trackIndex UTrackEntry* USpineSkeletonAnimationComponent::GetCurrent (int trackIndex) { CheckState(); - if (state) { + if (state && state->getCurrent(trackIndex)) { TrackEntry* entry = state->getCurrent(trackIndex); if (entry->getRendererObject()) { return (UTrackEntry*)entry->getRendererObject(); diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp index 95bc24e2c..64357a7db 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp @@ -436,7 +436,7 @@ UTrackEntry* USpineWidget::AddEmptyAnimation(int trackIndex, float mixDuration, UTrackEntry* USpineWidget::GetCurrent(int trackIndex) { CheckState(); - if (state) { + if (state && state->getCurrent(trackIndex)) { TrackEntry* entry = state->getCurrent(trackIndex); if (entry->getRendererObject()) { return (UTrackEntry*)entry->getRendererObject();