From 0dad4860c1f127f7891914f461b1594345d02df0 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 8 Jun 2021 00:29:51 +0200 Subject: [PATCH] dispose of the panel's render target --- MLEM.Ui/Elements/Panel.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index d5f0dcb..a9633fb 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -15,7 +15,7 @@ namespace MLEM.Ui.Elements { /// Additionally, a panel can be set to on construction, which causes all elements that don't fit into the panel to be hidden until scrolled to using a . /// As this behavior is accomplished using a , scrolling panels need to have their methods called using . /// - public class Panel : Element { + public class Panel : Element, IDisposable { /// /// The texture that this panel should have, or null if it should be invisible. @@ -76,6 +76,10 @@ namespace MLEM.Ui.Elements { } } + ~Panel() { + this.Dispose(); + } + /// public override void ForceUpdateArea() { if (this.scrollOverflow) { @@ -231,5 +235,13 @@ namespace MLEM.Ui.Elements { } } + /// + public void Dispose() { + if (this.renderTarget != null) { + this.renderTarget.Dispose(); + this.renderTarget = null; + } + } + } } \ No newline at end of file