Fix crash when animation has anim events and scripting is disposed before content
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -163,6 +163,11 @@ private:
|
||||
|
||||
void OnSkinnedModelUnloaded(Asset* obj);
|
||||
|
||||
public:
|
||||
|
||||
// [BinaryAsset]
|
||||
void OnScriptingDispose() override;
|
||||
|
||||
protected:
|
||||
|
||||
// [BinaryAsset]
|
||||
|
||||
Reference in New Issue
Block a user