修复atlas null 引用导致的闪退
This commit is contained in:
@@ -49,7 +49,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
||||
|
||||
public SpineObject36(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
||||
{
|
||||
atlas = new Atlas(AtlasPath, textureLoader);
|
||||
try { atlas = new Atlas(AtlasPath, textureLoader); }
|
||||
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); }
|
||||
try
|
||||
{
|
||||
// 先尝试二进制文件
|
||||
@@ -69,6 +70,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
||||
catch
|
||||
{
|
||||
// 都不行就报错
|
||||
atlas.Dispose();
|
||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||
}
|
||||
}
|
||||
@@ -95,7 +97,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
atlas.Dispose();
|
||||
atlas?.Dispose();
|
||||
}
|
||||
|
||||
public override string FileVersion { get => skeletonData.Version; }
|
||||
|
||||
Reference in New Issue
Block a user