From 1897248bda4873654bc79cddebb8a9119f16467a Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 4 Nov 2025 17:55:18 +0100 Subject: [PATCH] Misc: added assert to detect ~ImGuiContext() called without DestroyContext(). (#9051) --- imgui.cpp | 5 +++++ imgui_internal.h | 1 + 2 files changed, 6 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index dc7fa4440..46a6fd79d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4277,6 +4277,11 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas) memset(TempKeychordName, 0, sizeof(TempKeychordName)); } +ImGuiContext::~ImGuiContext() +{ + IM_ASSERT(Initialized == false && "Forgot to call DestroyContext()?"); +} + void ImGui::Initialize() { ImGuiContext& g = *GImGui; diff --git a/imgui_internal.h b/imgui_internal.h index 8da4e1aa4..810036b96 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2546,6 +2546,7 @@ struct ImGuiContext char TempKeychordName[64]; ImGuiContext(ImFontAtlas* shared_font_atlas); + ~ImGuiContext(); }; //-----------------------------------------------------------------------------