From 39fe42748769009ab699693c9fae264f6b5d06cf Mon Sep 17 00:00:00 2001 From: KHeartz Date: Mon, 31 Aug 2026 11:49:20 -0400 Subject: [PATCH] ImGui: guard ShowCursor against a torn-down context ShowCursor was the only entry point not checking isContextInitialized; a disconnect path calling it after Shutdown() crashed on a null context. Shutdown() also cleared the flag after DestroyContext(); clear it first. --- code/framework/src/external/imgui/wrapper.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/framework/src/external/imgui/wrapper.cpp b/code/framework/src/external/imgui/wrapper.cpp index 8c40d0373..1e77ab475 100644 --- a/code/framework/src/external/imgui/wrapper.cpp +++ b/code/framework/src/external/imgui/wrapper.cpp @@ -131,6 +131,9 @@ namespace Framework::External::ImGUI { if (!isContextInitialized) { return; } + // Cleared before teardown, not after: the backends and the context go away + // below, so anything gated on this flag must already see "not initialized". + isContextInitialized = false; switch (_config.renderBackend) { case Graphics::RendererBackend::BACKEND_D3D_9: { @@ -152,7 +155,6 @@ namespace Framework::External::ImGUI { ImGui::DestroyContext(); - isContextInitialized = false; Lifecycle::Shutdown(); } @@ -255,6 +257,10 @@ namespace Framework::External::ImGUI { } void Wrapper::ShowCursor(bool show) { + // Reachable from teardown paths after Shutdown() or a failed Init(). + if (!isContextInitialized) { + return; + } ImGuiIO &io = ImGui::GetIO(); io.MouseDrawCursor = show; }