diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2011-05-07 21:15:13 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2011-05-07 21:15:13 +0200 |
commit | 00e8503d301acc98c012b4ebd5467ebcd99915d0 (patch) | |
tree | 8d4bad9142a375566f558ae3f866534cf5d043aa | |
parent | 36ea730a7024db3a9738183f870367153f1b1578 (diff) | |
download | graphlcd-base-00e8503d301acc98c012b4ebd5467ebcd99915d0.tar.gz graphlcd-base-00e8503d301acc98c012b4ebd5467ebcd99915d0.tar.bz2 |
store failed image paths in image cache and take these into account when loading images -> no more flooding of /var/log/messages
-rw-r--r-- | glcdskin/cache.c | 11 | ||||
-rw-r--r-- | glcdskin/cache.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/glcdskin/cache.c b/glcdskin/cache.c index 83629a0..fdcb4b8 100644 --- a/glcdskin/cache.c +++ b/glcdskin/cache.c @@ -48,6 +48,7 @@ cImageCache::~cImageCache() delete images[i]; } images.clear(); + failedpaths.clear(); } cImage * cImageCache::Get(const std::string & path) @@ -57,6 +58,14 @@ cImage * cImageCache::Get(const std::string & path) uint64_t maxCounter; std::vector <cImageItem *>::iterator oldest; + // test if this path has already been stored as invalid path / invalid/non-existent image + for (size_t i = 0; i < failedpaths.size(); i++) { + if (failedpaths[i] == path) { + return NULL; + } + } + + maxCounter = 0; item = NULL; for (it = images.begin(); it != images.end(); it++) @@ -90,6 +99,8 @@ cImage * cImageCache::Get(const std::string & path) } images.push_back(item); return item->Image(); + } else { + failedpaths.push_back(path); } return NULL; } diff --git a/glcdskin/cache.h b/glcdskin/cache.h index 925ebcc..3862b51 100644 --- a/glcdskin/cache.h +++ b/glcdskin/cache.h @@ -46,6 +46,7 @@ private: cSkin * skin; size_t size; std::vector <cImageItem *> images; + std::vector <std::string> failedpaths; cImageItem * LoadImage(const std::string & path); public: |