From 7ee8f786f261f32a1b6700dc3b209618a748c09b Mon Sep 17 00:00:00 2001 From: dsa-t Date: Mon, 1 Jul 2024 15:23:55 +0000 Subject: [PATCH] Don't try to clear empty bitmap cache. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18310 (cherry picked from commit e5a5b59ac14e294afdfb4c241b67a179cc33fbf5) Co-authored-by: Alex Shvartzkop --- common/gal/opengl/opengl_gal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index a4c319f575..4dd86ea55c 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -255,7 +255,8 @@ GLuint GL_BITMAP_CACHE::cacheBitmap( const BITMAP_BASE* aBitmap ) bmp.accessTime = currentTime; #ifndef DISABLE_BITMAP_CACHE - if( m_cacheLru.size() + 1 > m_cacheMaxElements || m_cacheSize + bmp.size > m_cacheMaxSize ) + if( ( m_cacheLru.size() + 1 > m_cacheMaxElements || m_cacheSize + bmp.size > m_cacheMaxSize ) + && !m_cacheLru.empty() ) { KIID toRemove( 0 ); auto toRemoveLru = m_cacheLru.end();