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; }