From 6e26fd7e143a2d233a491b80dea0825e18596f73 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Tue, 28 Apr 2026 16:16:18 +0200 Subject: [PATCH] And one more --- lib/GfxRenderer/FontCacheManager.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/GfxRenderer/FontCacheManager.cpp b/lib/GfxRenderer/FontCacheManager.cpp index d8e46855..ded021da 100644 --- a/lib/GfxRenderer/FontCacheManager.cpp +++ b/lib/GfxRenderer/FontCacheManager.cpp @@ -15,6 +15,10 @@ void FontCacheManager::setFontDecompressor(FontDecompressor* d) { fontDecompress void FontCacheManager::clearCache() { if (fontDecompressor_) fontDecompressor_->clearCache(); for (auto& [id, font] : sdCardFonts_) { + if (!font) { + LOG_ERR("FCM", "clearCache: null SdCardFont pointer for fontId=%d", id); + continue; + } font->clearCache(); } } @@ -23,8 +27,15 @@ void FontCacheManager::prewarmCache(int fontId, const char* utf8Text, uint8_t st // SD card font prewarm path: prewarm all requested styles in one call auto sdIt = sdCardFonts_.find(fontId); if (sdIt != sdCardFonts_.end()) { - int missed = sdIt->second->prewarm(utf8Text, styleMask); - if (missed > 0) { + SdCardFont* sdFont = sdIt->second; + if (!sdFont) { + LOG_ERR("FCM", "prewarmCache(SD): null SdCardFont pointer for fontId=%d", fontId); + return; + } + int missed = sdFont->prewarm(utf8Text, styleMask); + if (missed < 0) { + LOG_ERR("FCM", "prewarmCache(SD): prewarm failed for fontId=%d (styleMask=0x%02X)", fontId, styleMask); + } else if (missed > 0) { LOG_DBG("FCM", "prewarmCache(SD): %d glyph(s) not found (styleMask=0x%02X)", missed, styleMask); } return; @@ -48,14 +59,14 @@ void FontCacheManager::prewarmCache(int fontId, const char* utf8Text, uint8_t st void FontCacheManager::logStats(const char* label) { if (fontDecompressor_) fontDecompressor_->logStats(label); for (auto& [id, font] : sdCardFonts_) { - font->logStats(label); + if (font) font->logStats(label); } } void FontCacheManager::resetStats() { if (fontDecompressor_) fontDecompressor_->resetStats(); for (auto& [id, font] : sdCardFonts_) { - font->resetStats(); + if (font) font->resetStats(); } }