Fix crash when animation has anim events and scripting is disposed before content

This commit is contained in:
Wojtek Figat
2022-01-08 18:29:13 +01:00
parent 82a43dea28
commit 844fad2ced
2 changed files with 23 additions and 0 deletions

View File

@@ -502,6 +502,24 @@ void Animation::OnSkinnedModelUnloaded(Asset* obj)
MappingCache.Remove(i);
}
void Animation::OnScriptingDispose()
{
// Dispose any events to prevent crashes (scripting is released before content)
for (auto& e : Events)
{
for (auto& k : e.Second.GetKeyframes())
{
if (k.Value.Instance)
{
Delete(k.Value.Instance);
k.Value.Instance = nullptr;
}
}
}
BinaryAsset::OnScriptingDispose();
}
Asset::LoadResult Animation::load()
{
// Get stream with animations data