Просмотр исходного кода

Misc: During shutdown, check that io.BackendPlatformUserData and io.BackendRendererUserData are NULL. (#7175)

ocornut 1 год назад
Родитель
Сommit
33d18c580b
2 измененных файлов с 7 добавлено и 1 удалено
  1. 3 0
      docs/CHANGELOG.txt
  2. 4 1
      imgui.cpp

+ 3 - 0
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

+ 4 - 1
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;