mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 14:56:35 +00:00
ImVector: added clear_delete(), clear_destruct() helpers.
# Conflicts: # imgui.cpp
This commit is contained in:
parent
865b2ca6f9
commit
4161a67b38
15
imgui.cpp
15
imgui.cpp
@ -2971,8 +2971,7 @@ ImGuiWindow::~ImGuiWindow()
|
|||||||
{
|
{
|
||||||
IM_ASSERT(DrawList == &DrawListInst);
|
IM_ASSERT(DrawList == &DrawListInst);
|
||||||
IM_DELETE(Name);
|
IM_DELETE(Name);
|
||||||
for (int i = 0; i != ColumnsStorage.Size; i++)
|
ColumnsStorage.clear_destruct();
|
||||||
ColumnsStorage[i].~ImGuiOldColumns();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
|
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
|
||||||
@ -4343,9 +4342,7 @@ void ImGui::Shutdown(ImGuiContext* context)
|
|||||||
CallContextHooks(&g, ImGuiContextHookType_Shutdown);
|
CallContextHooks(&g, ImGuiContextHookType_Shutdown);
|
||||||
|
|
||||||
// Clear everything else
|
// Clear everything else
|
||||||
for (int i = 0; i < g.Windows.Size; i++)
|
g.Windows.clear_delete();
|
||||||
IM_DELETE(g.Windows[i]);
|
|
||||||
g.Windows.clear();
|
|
||||||
g.WindowsFocusOrder.clear();
|
g.WindowsFocusOrder.clear();
|
||||||
g.WindowsTempSortBuffer.clear();
|
g.WindowsTempSortBuffer.clear();
|
||||||
g.CurrentWindow = NULL;
|
g.CurrentWindow = NULL;
|
||||||
@ -4362,18 +4359,14 @@ void ImGui::Shutdown(ImGuiContext* context)
|
|||||||
g.BeginPopupStack.clear();
|
g.BeginPopupStack.clear();
|
||||||
|
|
||||||
g.CurrentViewport = g.MouseViewport = g.MouseLastHoveredViewport = NULL;
|
g.CurrentViewport = g.MouseViewport = g.MouseLastHoveredViewport = NULL;
|
||||||
for (int i = 0; i < g.Viewports.Size; i++)
|
g.Viewports.clear_delete();
|
||||||
IM_DELETE(g.Viewports[i]);
|
|
||||||
g.Viewports.clear();
|
|
||||||
|
|
||||||
g.TabBars.Clear();
|
g.TabBars.Clear();
|
||||||
g.CurrentTabBarStack.clear();
|
g.CurrentTabBarStack.clear();
|
||||||
g.ShrinkWidthBuffer.clear();
|
g.ShrinkWidthBuffer.clear();
|
||||||
|
|
||||||
g.Tables.Clear();
|
g.Tables.Clear();
|
||||||
for (int i = 0; i < g.TablesTempDataStack.Size; i++)
|
g.TablesTempDataStack.clear_destruct();
|
||||||
g.TablesTempDataStack[i].~ImGuiTableTempData();
|
|
||||||
g.TablesTempDataStack.clear();
|
|
||||||
g.DrawChannelsTempMergeBuffer.clear();
|
g.DrawChannelsTempMergeBuffer.clear();
|
||||||
|
|
||||||
g.ClipboardHandlerData.clear();
|
g.ClipboardHandlerData.clear();
|
||||||
|
9
imgui.h
9
imgui.h
@ -62,7 +62,7 @@ Index of this file:
|
|||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.84 WIP"
|
#define IMGUI_VERSION "1.84 WIP"
|
||||||
#define IMGUI_VERSION_NUM 18306
|
#define IMGUI_VERSION_NUM 18307
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||||
@ -1743,7 +1743,11 @@ struct ImVector
|
|||||||
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
||||||
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
||||||
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
||||||
inline ~ImVector() { if (Data) IM_FREE(Data); }
|
inline ~ImVector() { if (Data) IM_FREE(Data); } // Important: does not destruct anything
|
||||||
|
|
||||||
|
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } // Important: does not destruct anything
|
||||||
|
inline void clear_delete() { for (int n = 0; n < Size; n++) IM_DELETE(Data[n]); clear(); } // Important: never called automatically! always explicit.
|
||||||
|
inline void clear_destruct() { for (int n = 0; n < Size; n++) Data[n].~T(); clear(); } // Important: never called automatically! always explicit.
|
||||||
|
|
||||||
inline bool empty() const { return Size == 0; }
|
inline bool empty() const { return Size == 0; }
|
||||||
inline int size() const { return Size; }
|
inline int size() const { return Size; }
|
||||||
@ -1753,7 +1757,6 @@ struct ImVector
|
|||||||
inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
||||||
inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; }
|
||||||
|
|
||||||
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
|
|
||||||
inline T* begin() { return Data; }
|
inline T* begin() { return Data; }
|
||||||
inline const T* begin() const { return Data; }
|
inline const T* begin() const { return Data; }
|
||||||
inline T* end() { return Data + Size; }
|
inline T* end() { return Data + Size; }
|
||||||
|
@ -2012,9 +2012,7 @@ void ImFontAtlas::ClearTexData()
|
|||||||
void ImFontAtlas::ClearFonts()
|
void ImFontAtlas::ClearFonts()
|
||||||
{
|
{
|
||||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||||
for (int i = 0; i < Fonts.Size; i++)
|
Fonts.clear_delete();
|
||||||
IM_DELETE(Fonts[i]);
|
|
||||||
Fonts.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlas::Clear()
|
void ImFontAtlas::Clear()
|
||||||
@ -2574,9 +2572,8 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup temporary (ImVector doesn't honor destructor)
|
// Cleanup
|
||||||
for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
|
src_tmp_array.clear_destruct();
|
||||||
src_tmp_array[src_i].~ImFontBuildSrcData();
|
|
||||||
|
|
||||||
ImFontAtlasBuildFinish(atlas);
|
ImFontAtlasBuildFinish(atlas);
|
||||||
return true;
|
return true;
|
||||||
|
@ -688,8 +688,7 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
|
|||||||
// Cleanup
|
// Cleanup
|
||||||
for (int buf_i = 0; buf_i < buf_bitmap_buffers.Size; buf_i++)
|
for (int buf_i = 0; buf_i < buf_bitmap_buffers.Size; buf_i++)
|
||||||
IM_FREE(buf_bitmap_buffers[buf_i]);
|
IM_FREE(buf_bitmap_buffers[buf_i]);
|
||||||
for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
|
src_tmp_array.clear_destruct();
|
||||||
src_tmp_array[src_i].~ImFontBuildSrcDataFT();
|
|
||||||
|
|
||||||
ImFontAtlasBuildFinish(atlas);
|
ImFontAtlasBuildFinish(atlas);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user