fix crash on swap chain resize

This commit is contained in:
zznty
2024-11-03 02:54:07 +07:00
parent 4da9022e16
commit ebc05073d8
2 changed files with 10 additions and 1 deletions

View File

@@ -52,7 +52,7 @@ internal class ImGuiHandler : IDisposable
public void DoRender() public void DoRender()
{ {
if (Rtv is null) if (Rtv is null)
throw new InvalidOperationException("Rtv is null"); return;
ImGui_ImplDX11_NewFrame(); ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame(); ImGui_ImplWin32_NewFrame();

View File

@@ -82,4 +82,13 @@ public static class SwapChainPatch
return false; return false;
} }
[HarmonyPrefix, HarmonyPatch(typeof(MyBackbuffer), nameof(MyBackbuffer.Release))]
private static void SwapChainBBReleasePrefix(MyBackbuffer __instance)
{
if (ImGuiHandler.Rtv is null) return;
ImGuiHandler.Rtv.Dispose();
ImGuiHandler.Rtv = null;
}
} }