修复atlas null 引用导致的闪退
This commit is contained in:
@@ -50,7 +50,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject21(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
public SpineObject21(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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -70,6 +71,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +98,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject36(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -69,6 +70,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject37(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
public SpineObject37(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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -66,6 +67,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +94,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject38(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
public SpineObject38(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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -70,6 +71,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}", ex);
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +98,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject40(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
public SpineObject40(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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -68,6 +69,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject41(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
public SpineObject41(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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -68,6 +69,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
|
|
||||||
public SpineObject42(string skelPath, string atlasPath) : base(skelPath, atlasPath)
|
public SpineObject42(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
|
try
|
||||||
{
|
{
|
||||||
// 先尝试二进制文件
|
// 先尝试二进制文件
|
||||||
@@ -68,6 +69,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
// 都不行就报错
|
// 都不行就报错
|
||||||
|
atlas.Dispose();
|
||||||
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
throw new InvalidDataException($"Unknown skeleton file format {SkelPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,7 @@ namespace SpineViewer.Spine.Implementations.SpineObject
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
atlas.Dispose();
|
atlas?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FileVersion { get => skeletonData.Version; }
|
public override string FileVersion { get => skeletonData.Version; }
|
||||||
|
|||||||
Reference in New Issue
Block a user