1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-26 10:19:22 +01:00

dispose of the panel's render target

This commit is contained in:
Ell 2021-06-08 00:29:51 +02:00
parent ed02a83879
commit 0dad4860c1

View file

@ -15,7 +15,7 @@ namespace MLEM.Ui.Elements {
/// Additionally, a panel can be set to <see cref="scrollOverflow"/> on construction, which causes all elements that don't fit into the panel to be hidden until scrolled to using a <see cref="ScrollBar"/>.
/// As this behavior is accomplished using a <see cref="RenderTarget2D"/>, scrolling panels need to have their <see cref="DrawEarly"/> methods called using <see cref="UiSystem.DrawEarly"/>.
/// </summary>
public class Panel : Element {
public class Panel : Element, IDisposable {
/// <summary>
/// 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();
}
/// <inheritdoc />
public override void ForceUpdateArea() {
if (this.scrollOverflow) {
@ -231,5 +235,13 @@ namespace MLEM.Ui.Elements {
}
}
/// <inheritdoc />
public void Dispose() {
if (this.renderTarget != null) {
this.renderTarget.Dispose();
this.renderTarget = null;
}
}
}
}