Add missing dispose calls
This commit is contained in:
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
public override object Create(ActorInitializer init) { return new ChronoVortexRenderer(init.Self); }
|
||||
}
|
||||
|
||||
public sealed class ChronoVortexRenderer : IRenderPostProcessPass
|
||||
public sealed class ChronoVortexRenderer : IRenderPostProcessPass, INotifyActorDisposing
|
||||
{
|
||||
readonly Renderer renderer;
|
||||
readonly IShader shader;
|
||||
@@ -105,5 +105,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
vortices.Clear();
|
||||
}
|
||||
|
||||
void INotifyActorDisposing.Disposing(Actor self)
|
||||
{
|
||||
vortexSheet.Dispose();
|
||||
vortexBuffer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public abstract class RenderPostProcessPassBase : IRenderPostProcessPass
|
||||
public abstract class RenderPostProcessPassBase : IRenderPostProcessPass, INotifyActorDisposing
|
||||
{
|
||||
readonly Renderer renderer;
|
||||
readonly IShader shader;
|
||||
@@ -52,5 +52,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected abstract bool Enabled { get; }
|
||||
protected abstract void PrepareRender(WorldRenderer wr, IShader shader);
|
||||
|
||||
void INotifyActorDisposing.Disposing(Actor self)
|
||||
{
|
||||
buffer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,5 +179,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
OnChange();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Removed()
|
||||
{
|
||||
mixerSheet?.Dispose();
|
||||
base.Removed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
Sprite hueSprite;
|
||||
Sprite pickerSprite;
|
||||
Sheet hueSheet;
|
||||
|
||||
public HueSliderWidget() { }
|
||||
public HueSliderWidget(HueSliderWidget other)
|
||||
@@ -28,7 +29,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
base.Initialize(args);
|
||||
|
||||
var hueSheet = new Sheet(SheetType.BGRA, new Size(256, 1));
|
||||
hueSheet = new Sheet(SheetType.BGRA, new Size(256, 1));
|
||||
|
||||
var buffer = new byte[4 * 256];
|
||||
|
||||
@@ -63,5 +64,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var pos = RenderOrigin + new int2(PxFromValue(Value).Clamp(0, rb.Width - 1) - (int)pickerSprite.Size.X / 2, (rb.Height - (int)pickerSprite.Size.Y) / 2);
|
||||
WidgetUtils.DrawSprite(pickerSprite, pos);
|
||||
}
|
||||
|
||||
public override void Removed()
|
||||
{
|
||||
hueSheet?.Dispose();
|
||||
base.Removed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly LabelWidget productionTime;
|
||||
readonly Widget productionPowerIcon;
|
||||
readonly LabelWidget productionPower;
|
||||
readonly List<Sheet> sheets = new();
|
||||
|
||||
ActorInfo selectedActor;
|
||||
ScrollItemWidget firstItem;
|
||||
@@ -81,6 +82,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
defaultPortrait = new Png(modData.DefaultFileSystem.Open("encyclopedia/default.png"));
|
||||
var spriteBounds = new Rectangle(0, 0, defaultPortrait.Width, defaultPortrait.Height);
|
||||
var sheet = new Sheet(SheetType.BGRA, spriteBounds.Size.NextPowerOf2());
|
||||
sheets.Add(sheet);
|
||||
sheet.CreateBuffer();
|
||||
sheet.GetTexture().ScaleFilter = TextureScaleFilter.Linear;
|
||||
portraitSprite = new Sprite(sheet, spriteBounds, TextureChannel.RGBA);
|
||||
@@ -304,5 +306,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
time = time * bi.BuildDurationModifier * pbi / 10000;
|
||||
return time;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
foreach (var sheet in sheets)
|
||||
sheet.Dispose();
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user