From 99093d5ac8dc4307769c324c2dbaf18849ad8706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 28 May 2011 14:39:31 +0300 Subject: (Re?)set bitmap cache size when initializing bitmaps. Without something like this, when built with gcc 4.6, the cache's max size ends up set to 0 (it's initialized before setup is done) and we crash in cache[]. --- HISTORY | 1 + bitmap.c | 1 + cache.h | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index a50fab5..6a315b4 100644 --- a/HISTORY +++ b/HISTORY @@ -7,6 +7,7 @@ VDR Plugin 'text2skin' Revision History - Documentation spelling fixes. - Added experimental RELAX NG schema for skin XML files. - Set minimum value of bitmap cache size in menu to 1. +- Fix bitmap cache size initialization when built with gcc 4.6. 2010-06-21: Version 1.3.1 diff --git a/bitmap.c b/bitmap.c index 5319333..8159536 100644 --- a/bitmap.c +++ b/bitmap.c @@ -90,6 +90,7 @@ void cText2SkinBitmap::Init(void) { #ifdef HAVE_IMAGEMAGICK InitializeMagick(NULL); #endif + mCache.SetMaxItems(Text2SkinSetup.MaxCacheFill); } cText2SkinBitmap::cText2SkinBitmap(void) { diff --git a/cache.h b/cache.h index b3cc782..f37e693 100644 --- a/cache.h +++ b/cache.h @@ -31,6 +31,7 @@ public: bool Contains(const key_type &Key); data_type &operator[](const key_type &Key); uint Count(void) { return mUsage.size(); } + void SetMaxItems(uint MaxItems) { mMaxItems = MaxItems; } }; template @@ -85,7 +86,7 @@ data_type &cxCache::operator[](const key_type &Key) return it->second; } - if (mUsage.size() == mMaxItems) { + while (mUsage.size() >= mMaxItems) { item_iterator it = mItems.find(*mUsage.begin()); DeleteObject(it->first, it->second); mUsage.erase(mUsage.begin()); -- cgit v1.2.3