From a5185737e65ef4467893713ca6c843987639c4d0 Mon Sep 17 00:00:00 2001 From: DanS Date: Mon, 12 Oct 2026 13:22:00 -0500 Subject: [PATCH] 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 --- src/app.cpp | 9 ++++++--- src/app.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index f6c3b07..0cb3a0c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -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, diff --git a/src/app.h b/src/app.h index 5c28f93..349e68d 100644 --- a/src/app.h +++ b/src/app.h @@ -690,8 +690,8 @@ public: // Diagnostic string describing daemon memory detection path (for debugging) const std::string& getDaemonMemDiag() const { return daemon_mem_diag_; } - // Background gradient overlay texture - void setGradientTexture(ImTextureID tex) { gradient_tex_ = tex; } + // Background gradient overlay texture (a replaced texture is retired, freed at the next preFrame()) + void setGradientTexture(ImTextureID tex) { if (tex != gradient_tex_) retireTexture(gradient_tex_); gradient_tex_ = tex; } ImTextureID getGradientTexture() const { return gradient_tex_; } // Logo texture accessor (wallet branding icon)