diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 6d470ade6..3a4aca1ac 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -788,6 +788,7 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in return false; int yy = y; + bool freeicondata = false; //printf("CFrameBuffer::paintIcon: load %s\n", filename.c_str());fflush(stdout); /* we cache and check original name */ @@ -872,6 +873,8 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in cache_size += dsize; icon_cache.insert(std::pair (filename, tmpIcon)); //printf("Cached %s, cache size %d\n", newname.c_str(), cache_size); + }else{ + freeicondata = true; } } else { data = it->second.data; @@ -880,9 +883,13 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in //printf("paintIcon: already cached %s %d x %d\n", newname.c_str(), width, height); } _display: - if(!paint) + if(!paint){ + if(freeicondata){ + free(data); + data = NULL; + } return true; - + } if (h != 0) yy += (h - height) / 2; @@ -1351,7 +1358,7 @@ void CFrameBuffer::useBackground(bool ub) useBackgroundPaint = ub; if(!useBackgroundPaint) { delete[] background; - background=0; + background=NULL; } } @@ -1374,10 +1381,11 @@ void CFrameBuffer::saveBackgroundImage(void) void CFrameBuffer::restoreBackgroundImage(void) { - fb_pixel_t * tmp = background; + fb_pixel_t * tmp = NULL; if (backupBackground != NULL) { + tmp = background; background = backupBackground; backupBackground = NULL; }