From 33d18c580bd24109fe2d31cc57e31704df749001 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Jan 2024 14:56:21 +0100 Subject: [PATCH] Misc: During shutdown, check that io.BackendPlatformUserData and io.BackendRendererUserData are NULL. (#7175) --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 6af62ec1c..291030a9a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -72,6 +72,7 @@ Other changes: to allow passing through multiple widgets easily. (#3092, #5759, #787) - Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text editing. Invalid inputs not applied to value, visibly reverted after validation. (#6810, #7096) +- Drags, Sliders, Inputs: removal of filter means that "nan" and "inf" values may be input. (#7096) - DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components width computation to better distribute the error. (#7120, #7121) [@Nahor] - ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121) @@ -90,6 +91,8 @@ Other changes: like most printf implementations. (#7016, #3466, #6846) [@codefrog2002] - Misc: Renamed some defines in imstb_textedit.h to avoid conflicts when using unity/jumbo builds on a codebase where another copy of the library is used. +- Misc: During shutdown, check that io.BackendPlatformUserData and io.BackendRendererUserData are NULL + in order to catch cases where backend was not shut down. (#7175) - Backends: GLFW, Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to register canvas selector and auto-resize GLFW window. (#6751) [@Traveller23, @ypujante] - Backends: GLFW: Fixed Windows specific hooks to use Unicode version of WndProc even when diff --git a/imgui.cpp b/imgui.cpp index 77661fa96..f5dc8f02f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3604,8 +3604,11 @@ void ImGui::Initialize() // This function is merely here to free heap allocations. void ImGui::Shutdown() { - // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) ImGuiContext& g = *GImGui; + IM_ASSERT_USER_ERROR(g.IO.BackendPlatformUserData == NULL, "Forgot to shutdown Platform backend?"); + IM_ASSERT_USER_ERROR(g.IO.BackendRendererUserData == NULL, "Forgot to shutdown Renderer backend?"); + + // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) if (g.IO.Fonts && g.FontAtlasOwnedByContext) { g.IO.Fonts->Locked = false;