WIP - Fixed leak due to indirectly recursing ImFontAtlasPackInit().

This commit is contained in:
ocornut 2025-01-23 12:12:07 +01:00
parent 9b96eb3b43
commit e62ef00f65

View file

@ -3860,8 +3860,6 @@ void ImFontAtlasBuildCompactTexture(ImFontAtlas* atlas)
// Start packing over current empty texture
void ImFontAtlasBuildInit(ImFontAtlas* atlas)
{
ImFontAtlasBuilder* builder = atlas->Builder;
// Select Backend
// - Note that we do not reassign to atlas->FontLoader, since it is likely to point to static data which
// may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are
@ -3876,14 +3874,20 @@ void ImFontAtlasBuildInit(ImFontAtlas* atlas)
#else
IM_ASSERT(0); // Invalid Build function
#endif
return; // ImFontAtlasBuildSetupFontBackendIO() automatically call ImFontAtlasBuildInit()
}
// Create initial texture size
if (atlas->TexData == NULL)
ImFontAtlasBuildAddTexture(atlas, ImUpperPowerOfTwo(atlas->TexMinWidth), ImUpperPowerOfTwo(atlas->TexMinHeight));
ImFontAtlasBuilder* builder = atlas->Builder; // Do not move above
const bool builder_is_new = (builder == NULL);
if (builder_is_new)
{
IM_ASSERT(atlas->Builder == NULL);
builder = atlas->Builder = IM_NEW(ImFontAtlasBuilder)();
}
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(atlas);