DrawList, Fonts: fixed ImFontAtlasTextureRepack() overwriting draw list shared data UV's etc. even when not bound. (#8694, #8465)

ImFontAtlasUpdateDrawListsSharedData() call from ImFontAtlasTextureRepack() would trigger this.
For simplicity we also track current atlas in ImDrawListSharedData, but we could probably use Font->ContainerAtlas.
This commit is contained in:
ocornut
2025-06-17 11:55:40 +02:00
parent 842837e35b
commit 24f7328e5f
3 changed files with 20 additions and 15 deletions

View File

@@ -2694,10 +2694,11 @@ void ImFontAtlas::ClearFonts()
Fonts.clear_delete();
TexIsBuilt = false;
for (ImDrawListSharedData* shared_data : DrawListSharedDatas)
{
shared_data->Font = NULL;
shared_data->FontScale = shared_data->FontSize = 0.0f;
}
if (shared_data->FontAtlas == this)
{
shared_data->Font = NULL;
shared_data->FontScale = shared_data->FontSize = 0.0f;
}
}
static void ImFontAtlasBuildUpdateRendererHasTexturesFromContext(ImFontAtlas* atlas)
@@ -3914,10 +3915,11 @@ void ImFontAtlasUpdateDrawListsTextures(ImFontAtlas* atlas, ImTextureRef old_tex
void ImFontAtlasUpdateDrawListsSharedData(ImFontAtlas* atlas)
{
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
{
shared_data->TexUvWhitePixel = atlas->TexUvWhitePixel;
shared_data->TexUvLines = atlas->TexUvLines;
}
if (shared_data->FontAtlas == atlas)
{
shared_data->TexUvWhitePixel = atlas->TexUvWhitePixel;
shared_data->TexUvLines = atlas->TexUvLines;
}
}
// Set current texture. This is mostly called from AddTexture() + to handle a failed resize.