Add missing dispose calls

This commit is contained in:
Gustas
2025-03-10 18:45:14 +02:00
committed by Paul Chote
parent c9ac702217
commit ec01f63317
6 changed files with 46 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ namespace OpenRA.Mods.Common.Widgets
readonly Stopwatch playTime = new();
int textureWidth;
int textureHeight;
Sheet videoSheet;
Action onComplete;
@@ -123,7 +124,8 @@ namespace OpenRA.Mods.Common.Widgets
textureWidth = Exts.NextPowerOf2(video.Width);
textureHeight = Exts.NextPowerOf2(video.Height);
var videoSheet = new Sheet(SheetType.BGRA, new Size(textureWidth, textureHeight));
videoSheet?.Dispose();
videoSheet = new Sheet(SheetType.BGRA, new Size(textureWidth, textureHeight));
videoSheet.GetTexture().ScaleFilter = TextureScaleFilter.Linear;
videoSheet.GetTexture().SetData(video.CurrentFrameData, textureWidth, textureHeight);
@@ -301,5 +303,11 @@ namespace OpenRA.Mods.Common.Widgets
Stop();
Video = null;
}
public override void Removed()
{
videoSheet?.Dispose();
overlaySheet?.Dispose();
}
}
}