1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-09 23:54:20 +00:00

Fonts: calling ImFontAtlas::Clear() mid-frame without re-adding a font will lead to a more explicit crash. (#9067)

+ reformat Changelog.
This commit is contained in:
ocornut 2025-11-13 15:54:36 +01:00
parent d246850787
commit ec6219752d
4 changed files with 21 additions and 13 deletions

View file

@ -79,17 +79,21 @@ Other Changes:
to auto-size on a given axis would keep marking ini settings as dirty. to auto-size on a given axis would keep marking ini settings as dirty.
- Disabled: fixed a bug when a previously enabled item that got nav focus - Disabled: fixed a bug when a previously enabled item that got nav focus
and then turns disabled could still be activated using keyboard. (#9036) and then turns disabled could still be activated using keyboard. (#9036)
- InputText: when buffer is not resizable, trying to paste contents that - InputText:
cannot fit will now truncate text to nearest UTF-8 codepoint boundaries, - When buffer is not resizable, trying to paste contents that cannot
instead of completely ignoring the paste. (#9029) fit will now truncate text to nearest UTF-8 codepoint boundaries,
- InputText: avoid continuously overwriting ownership of ImGuiKey_Enter/_KeypadEnter instead of completely ignoring the paste. (#9029)
keys in order to allow e.g. external Shortcut override behavior. (#9004) - Avoid continuously overwriting ownership of ImGuiKey_Enter/_KeypadEnter
- InputText: when using a callback to reduce/manipulate the value of BufTextLen, keys in order to allow e.g. external Shortcut override behavior. (#9004)
we do not require anymore that CursorPos be clamped by user code. (#9029) - When using a callback to reduce/manipulate the value of BufTextLen,
- InputTextMultiline: fixed a crash when using ImGuiInputTextFlags_WordWrap and we do not require anymore that CursorPos be clamped by user code. (#9029)
resizing the parent window while keeping the multi-line field active (which is - InputTextMultiline: fixed a crash when using ImGuiInputTextFlags_WordWrap and
most typically achieved when resizing programmatically or via a docking layout resizing the parent window while keeping the multi-line field active (which is
reacting to a platform window resize). (#3237, #9007) [@anton-kl, @ocornut] most typically achieved when resizing programmatically or via a docking layout
reacting to a platform window resize). (#3237, #9007) [@anton-kl, @ocornut]
- Fonts:
- Calling ImFontAtlas::Clear() mid-frame without re-adding a font will
lead to a more explicit crash.
- Textures: - Textures:
- Fixed an issue preventing multi-contexts from using each others' fonts - Fixed an issue preventing multi-contexts from using each others' fonts
if context 2 runs after context 1's Render() function. (#9039) if context 2 runs after context 1's Render() function. (#9039)

View file

@ -3638,7 +3638,7 @@ struct ImFontAtlas
IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels = 0.0f, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter. IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels = 0.0f, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
IMGUI_API void RemoveFont(ImFont* font); IMGUI_API void RemoveFont(ImFont* font);
IMGUI_API void Clear(); // Clear everything (input fonts, output glyphs/textures) IMGUI_API void Clear(); // Clear everything (input fonts, output glyphs/textures).
IMGUI_API void CompactCache(); // Compact cached glyphs and texture. IMGUI_API void CompactCache(); // Compact cached glyphs and texture.
IMGUI_API void SetFontLoader(const ImFontLoader* font_loader); // Change font loader at runtime. IMGUI_API void SetFontLoader(const ImFontLoader* font_loader); // Change font loader at runtime.

View file

@ -2656,6 +2656,7 @@ ImFontAtlas::~ImFontAtlas()
TexData = NULL; TexData = NULL;
} }
// If you call this mid-frame, you would need to add new font and bind them!
void ImFontAtlas::Clear() void ImFontAtlas::Clear()
{ {
bool backup_renderer_has_textures = RendererHasTextures; bool backup_renderer_has_textures = RendererHasTextures;
@ -2706,6 +2707,8 @@ void ImFontAtlas::ClearFonts()
{ {
// FIXME-NEWATLAS: Illegal to remove currently bound font. // FIXME-NEWATLAS: Illegal to remove currently bound font.
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!"); IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
for (ImFont* font : Fonts)
ImFontAtlasBuildNotifySetFont(this, font, NULL);
ImFontAtlasBuildDestroy(this); ImFontAtlasBuildDestroy(this);
ClearInputData(); ClearInputData();
Fonts.clear_delete(); Fonts.clear_delete();
@ -3200,7 +3203,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
// On font removal we need to remove references (otherwise we could queue removal?) // On font removal we need to remove references (otherwise we could queue removal?)
// We allow old_font == new_font which forces updating all values (e.g. sizes) // We allow old_font == new_font which forces updating all values (e.g. sizes)
static void ImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font, ImFont* new_font) void ImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font, ImFont* new_font)
{ {
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas) for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
{ {

View file

@ -3856,6 +3856,7 @@ IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
IMGUI_API void ImFontAtlasBuildDestroy(ImFontAtlas* atlas); IMGUI_API void ImFontAtlasBuildDestroy(ImFontAtlas* atlas);
IMGUI_API void ImFontAtlasBuildMain(ImFontAtlas* atlas); IMGUI_API void ImFontAtlasBuildMain(ImFontAtlas* atlas);
IMGUI_API void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* font_loader); IMGUI_API void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* font_loader);
IMGUI_API void ImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font, ImFont* new_font);
IMGUI_API void ImFontAtlasBuildUpdatePointers(ImFontAtlas* atlas); IMGUI_API void ImFontAtlasBuildUpdatePointers(ImFontAtlas* atlas);
IMGUI_API void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char); IMGUI_API void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char);
IMGUI_API void ImFontAtlasBuildClear(ImFontAtlas* atlas); // Clear output and custom rects IMGUI_API void ImFontAtlasBuildClear(ImFontAtlas* atlas); // Clear output and custom rects