summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-06-22 22:00:45 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-06-22 22:00:45 -0400
commit239052759fed3abfe9811fddf6e5d3d10bc14e35 (patch)
tree2377950562c72805d624e19fd9b02e9241623794
parent32924aa7b8809172eb960245b1982ec7cda590e6 (diff)
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
-rw-r--r--libs/canvas/wave_view.cc58
1 files changed, 29 insertions, 29 deletions
diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc
index 9dca22ecca..9c869c9392 100644
--- a/libs/canvas/wave_view.cc
+++ b/libs/canvas/wave_view.cc
@@ -1722,45 +1722,45 @@ WaveViewCache::cache_flush ()
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());
ImageCache::iterator x;
- if ((x = cache_map.find (le.first)) == cache_map.end ()) {
- /* wierd ... no entry for this AudioSource */
- continue;
- }
+ if ((x = cache_map.find (le.first)) != cache_map.end ()) {
- CacheLine& cl = x->second;
-
- for (CacheLine::iterator c = cl.begin(); c != cl.end(); ++c) {
-
- if (*c == le.second) {
-
- /* Remove this entry from this cache line */
- cl.erase (c);
-
- if (cl.empty()) {
- /* remove cache line from main cache: no more entries */
- cache_map.erase (x);
+ CacheLine& cl = x->second;
+
+ for (CacheLine::iterator c = cl.begin(); c != cl.end(); ++c) {
+
+ if (*c == le.second) {
+
+ /* Remove this entry from this cache line */
+ cl.erase (c);
+
+ if (cl.empty()) {
+ /* remove cache line from main cache: no more entries */
+ 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());
}
}