mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
fix: correctly enqueue textures for destroy if they're GC'd
This commit is contained in:
parent
70d5cb5856
commit
14ce85627d
2 changed files with 26 additions and 5 deletions
|
|
@ -21,6 +21,14 @@ public class DalamudTextureWrap : TextureWrap
|
|||
this.wrappedWrap = wrappingWrap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes an instance of the <see cref="DalamudTextureWrap"/> class.
|
||||
/// </summary>
|
||||
~DalamudTextureWrap()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ImGui handle of the texture.
|
||||
/// </summary>
|
||||
|
|
@ -41,7 +49,8 @@ public class DalamudTextureWrap : TextureWrap
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Service<InterfaceManager>.Get().EnqueueDeferredDispose(this);
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -51,4 +60,12 @@ public class DalamudTextureWrap : TextureWrap
|
|||
{
|
||||
this.wrappedWrap.Dispose();
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Service<InterfaceManager>.GetNullable()?.EnqueueDeferredDispose(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -606,12 +606,16 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
|
||||
this.RenderImGui();
|
||||
|
||||
foreach (var texture in this.deferredDisposeTextures)
|
||||
if (this.deferredDisposeTextures.Count > 0)
|
||||
{
|
||||
texture.RealDispose();
|
||||
}
|
||||
Log.Verbose("[IM] Disposing {Count} textures", this.deferredDisposeTextures.Count);
|
||||
foreach (var texture in this.deferredDisposeTextures)
|
||||
{
|
||||
texture.RealDispose();
|
||||
}
|
||||
|
||||
this.deferredDisposeTextures.Clear();
|
||||
this.deferredDisposeTextures.Clear();
|
||||
}
|
||||
|
||||
return this.presentHook.Original(swapChain, syncInterval, presentFlags);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue