diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-05-28 14:39:31 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-05-28 14:59:19 +0300 |
commit | 99093d5ac8dc4307769c324c2dbaf18849ad8706 (patch) | |
tree | e9e605c8649c5859da5cf5ada09899b59328e1c7 | |
parent | 9cacfd2419fe57111c12e8bcb66e5dab9b11d720 (diff) | |
download | vdr-plugin-text2skin-99093d5ac8dc4307769c324c2dbaf18849ad8706.tar.gz vdr-plugin-text2skin-99093d5ac8dc4307769c324c2dbaf18849ad8706.tar.bz2 |
(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[].
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | bitmap.c | 1 | ||||
-rw-r--r-- | cache.h | 3 |
3 files changed, 4 insertions, 1 deletions
@@ -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 @@ -90,6 +90,7 @@ void cText2SkinBitmap::Init(void) { #ifdef HAVE_IMAGEMAGICK InitializeMagick(NULL); #endif + mCache.SetMaxItems(Text2SkinSetup.MaxCacheFill); } cText2SkinBitmap::cText2SkinBitmap(void) { @@ -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<class key_type, class data_type> @@ -85,7 +86,7 @@ data_type &cxCache<key_type, data_type>::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()); |