Shutdown() freeing a few extra vectors so they don't have to freed by destruction #169

This commit is contained in:
ocornut 2015-03-21 00:41:34 +00:00
parent c0eab2a164
commit 92a22ab35f
2 changed files with 20 additions and 9 deletions

View File

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

View File

@ -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();