refactor(app): retire logo textures through the deferred-destroy queue

ensureLogoTexture() still freed the chat emoji, header logo and coin logo
textures it replaced at once, while every other theme-driven replacement
already goes through retireTexture() and is freed at the next preFrame().
It runs at the top of render(), so nothing referenced them yet; this is
hygiene, so that the same rule covers every replaced texture.

- ensureLogoTexture(): the three direct DestroyTexture() calls become
  retireTexture(). Cost: the old textures live one extra frame on a theme
  or accent change.
- setGradientTexture() (unused today) retires the texture it replaces
  instead of dropping it.
- No drain at shutdown: the process exits and the live logo and gradient
  textures are not freed at exit either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 13:22:00 -05:00
co-authored by Claude Opus 5.5
parent a581f42a33
commit a5185737e6
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -1790,19 +1790,22 @@ void App::ensureLogoTexture()
// colour on light skins so it doesn't wash out against a light card/background.
const ImU32 detailCol = wantDark ? IM_COL32(255, 255, 255, 255) : ui::material::OnSurface();
// Replaced textures are retired, not freed: the deferred-destroy queue frees them at the next preFrame(),
// after every draw list that may still reference them has been rendered.
// ":drgx:" custom chat emoji — themed to the accent like the logo (re-rasterized on theme change).
if (drgx_emoji_tex_) util::DestroyTexture(drgx_emoji_tex_);
retireTexture(drgx_emoji_tex_);
drgx_emoji_tex_ = 0; drgx_emoji_w_ = 0; drgx_emoji_h_ = 0;
util::LoadTextureFromSvg(embedded::kLogoDragonXSvg, 96, logoAccent, detailCol,
&drgx_emoji_tex_, &drgx_emoji_w_, &drgx_emoji_h_);
if (logo_tex_) util::DestroyTexture(logo_tex_); // free the previous texture before replacing
retireTexture(logo_tex_); // retire the previous texture before replacing
logo_tex_ = 0; logo_w_ = 0; logo_h_ = 0;
// Coin/currency icon (the big DragonX mark on the balance card) — the SAME themed SVG recolored to
// the accent, rasterized here so it changes with the skin too (done first, since the header block
// below early-returns on success). Falls back to the PNG coin icon if rasterization fails.
if (coin_logo_tex_) util::DestroyTexture(coin_logo_tex_);
retireTexture(coin_logo_tex_);
coin_logo_tex_ = 0; coin_logo_w_ = 0; coin_logo_h_ = 0;
coin_logo_loaded_ = true;
if (!util::LoadTextureFromSvg(embedded::kLogoDragonXSvg, 128, logoAccent, detailCol,