13
0

stop endless loop in WaveViewCache::cache_flush()

Still need to figure out how this could ever happen. It requires an image (shared pointer) to
be in the linear cache image list but not in the map
This commit is contained in:
Paul Davis 2015-06-22 22:00:45 -04:00
parent 32924aa7b8
commit 239052759f

View File

@ -1722,45 +1722,45 @@ WaveViewCache::cache_flush ()
sort (cache_list.begin(), cache_list.end(), sorter); sort (cache_list.begin(), cache_list.end(), sorter);
while (image_cache_size > _image_cache_threshold) { while (image_cache_size > _image_cache_threshold && !cache_map.empty() && !cache_list.empty()) {
ListEntry& le (cache_list.front()); ListEntry& le (cache_list.front());
ImageCache::iterator x; ImageCache::iterator x;
if ((x = cache_map.find (le.first)) == cache_map.end ()) { if ((x = cache_map.find (le.first)) != cache_map.end ()) {
/* wierd ... no entry for this AudioSource */
continue;
}
CacheLine& cl = x->second; CacheLine& cl = x->second;
for (CacheLine::iterator c = cl.begin(); c != cl.end(); ++c) { for (CacheLine::iterator c = cl.begin(); c != cl.end(); ++c) {
if (*c == le.second) { if (*c == le.second) {
/* Remove this entry from this cache line */ /* Remove this entry from this cache line */
cl.erase (c); cl.erase (c);
if (cl.empty()) { if (cl.empty()) {
/* remove cache line from main cache: no more entries */ /* remove cache line from main cache: no more entries */
cache_map.erase (x); cache_map.erase (x);
}
break;
} }
}
break;
Cairo::RefPtr<Cairo::ImageSurface> img (le.second->image);
uint64_t size = img->get_height() * img->get_width() * 4; /* 4 = bytes per FORMAT_ARGB32 pixel */
if (image_cache_size > size) {
image_cache_size -= size;
} else {
image_cache_size = 0;
} }
} }
Cairo::RefPtr<Cairo::ImageSurface> img (le.second->image);
uint64_t size = img->get_height() * img->get_width() * 4; /* 4 = bytes per FORMAT_ARGB32 pixel */
if (image_cache_size > size) {
image_cache_size -= size;
} else {
image_cache_size = 0;
}
/* Remove from the linear list */ /* Remove from the linear list, even if we didn't find it in
* the actual cache_mao
*/
cache_list.erase (cache_list.begin()); cache_list.erase (cache_list.begin());
} }
} }