diff --git a/imgui.cpp b/imgui.cpp index a18c0471..fcd87e4c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1975,8 +1975,6 @@ void ImGui::Shutdown() } g.Windows.clear(); g.CurrentWindowStack.clear(); - g.RenderDrawLists.clear(); - g.CursorDrawList.Clear(); g.FocusedWindow = NULL; g.HoveredWindow = NULL; g.HoveredRootWindow = NULL; @@ -1989,26 +1987,29 @@ void ImGui::Shutdown() g.ColorModifiers.clear(); g.StyleModifiers.clear(); g.FontStack.clear(); + g.RenderDrawLists.clear(); + g.RenderSortedWindows.clear(); + g.CursorDrawList.ClearFreeMemory(); g.ColorEditModeStorage.Clear(); - if (g.LogFile && g.LogFile != stdout) - { - fclose(g.LogFile); - g.LogFile = NULL; - } - g.IO.Fonts->Clear(); - if (g.PrivateClipboard) { ImGui::MemFree(g.PrivateClipboard); g.PrivateClipboard = NULL; } + if (g.LogFile && g.LogFile != stdout) + { + fclose(g.LogFile); + g.LogFile = NULL; + } if (g.LogClipboard) { g.LogClipboard->~ImGuiTextBuffer(); ImGui::MemFree(g.LogClipboard); } + g.IO.Fonts->Clear(); + g.Initialized = false; } @@ -7245,6 +7246,15 @@ void ImDrawList::Clear() texture_id_stack.resize(0); } +void ImDrawList::ClearFreeMemory() +{ + commands.clear(); + vtx_buffer.clear(); + vtx_write = NULL; + clip_rect_stack.clear(); + texture_id_stack.clear(); +} + void ImDrawList::AddDrawCmd() { ImDrawCmd draw_cmd; diff --git a/imgui.h b/imgui.h index 3319624b..e07ad465 100644 --- a/imgui.h +++ b/imgui.h @@ -865,6 +865,7 @@ struct ImDrawList ImDrawList() { Clear(); } IMGUI_API void Clear(); + IMGUI_API void ClearFreeMemory(); IMGUI_API void PushClipRect(const ImVec4& clip_rect); // Scissoring. The values are x1, y1, x2, y2. IMGUI_API void PushClipRectFullScreen(); IMGUI_API void PopClipRect();