From ff2dfc84226aaeab4200aa2334c4715590e9dc9e Mon Sep 17 00:00:00 2001 From: Elliot Prior <1709938+Quogu@users.noreply.github.com> Date: Tue, 22 Jul 2025 18:21:43 +0100 Subject: [PATCH] Fonts: fixed a crash when modifying different texture format with a legacy backend. (#8824) --- docs/CHANGELOG.txt | 3 +++ imgui_draw.cpp | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 21008e01d..049007155 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,6 +50,9 @@ Other Changes: specified but the target font doesn't. Usually either all fonts should have a reference size (only required when specifying e.g. GlyphOffset), or none should have a reference size. +- Fonts: fixed a crash when changing texture format when using a legacy + backend. Most commonly would happen when calling GetTexDataAsRGBA32() + then immediately GetTexDataAsAlpha8(). (#8824) - Windows: fixed an issue where resizable child windows would emit border logic when hidden/non-visible (e.g. when in a docked window that is not selected), impacting code not checking for BeginChild() return value. (#8815) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index ca1f912a4..8109ca6e0 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3363,11 +3363,7 @@ void ImFontAtlasBuildMain(ImFontAtlas* atlas) { IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!"); if (atlas->TexData && atlas->TexData->Format != atlas->TexDesiredFormat) - { - ImVec2i new_tex_size = ImFontAtlasTextureGetSizeEstimate(atlas); - ImFontAtlasBuildDestroy(atlas); - ImFontAtlasTextureAdd(atlas, new_tex_size.x, new_tex_size.y); - } + ImFontAtlasBuildClear(atlas); if (atlas->Builder == NULL) ImFontAtlasBuildInit(atlas);