Przeglądaj źródła

Fonts: fixed a crash when modifying different texture format with a legacy backend. (#8824)

Elliot Prior 2 miesięcy temu
rodzic
commit
ff2dfc8422
2 zmienionych plików z 4 dodań i 5 usunięć
  1. 3 0
      docs/CHANGELOG.txt
  2. 1 5
      imgui_draw.cpp

+ 3 - 0
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)

+ 1 - 5
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);