Delete font clear pointer in ImGui state to get a clear crasah instead of a dangling pointer. #181

docking
ocornut 10 years ago
parent b61b311772
commit 503b8c20de

@ -8264,6 +8264,16 @@ ImFont::ImFont()
Clear();
}
ImFont::~ImFont()
{
// Invalidate active font so that the user gets a clear crash instead of a dangling pointer.
// If you want to delete fonts you need to do it between Render() and NewFrame().
ImGuiState& g = *GImGui;
if (g.Font == this)
g.Font = NULL;
Clear();
}
void ImFont::Clear()
{
FontSize = 0.0f;

@ -998,7 +998,7 @@ struct ImFont
// Methods
IMGUI_API ImFont();
IMGUI_API ~ImFont() { Clear(); }
IMGUI_API ~ImFont();
IMGUI_API void Clear();
IMGUI_API void BuildLookupTable();
IMGUI_API const Glyph* FindGlyph(unsigned short c) const;

Loading…
Cancel
Save