changeset 1036:bc9b4a163926 spectrogram-minor-refactor

Fix cache validity boundary condition
author Chris Cannam
date Tue, 02 Feb 2016 14:28:00 +0000
parents 6d084d6d5015
children 6f7a471826d1
files layer/ScrollableImageCache.cpp
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/layer/ScrollableImageCache.cpp	Tue Feb 02 10:44:07 2016 +0000
+++ b/layer/ScrollableImageCache.cpp	Tue Feb 02 14:28:00 2016 +0000
@@ -100,16 +100,28 @@
 ScrollableImageCache::adjustToTouchValidArea(int &left, int &width,
 					     bool &isLeftOfValidArea) const
 {
+#ifdef DEBUG_SCROLLABLE_IMAGE_CACHE
+    cerr << "ScrollableImageCache::adjustToTouchValidArea: left " << left
+         << ", width " << width << endl;
+    cerr << "ScrollableImageCache: my left " << m_left
+         << ", width " << m_width << " so right " << (m_left + m_width) << endl;
+#endif
     if (left < m_left) {
 	isLeftOfValidArea = true;
-	if (left + width < m_left + m_width) {
+	if (left + width <= m_left + m_width) {
 	    width = m_left - left;
 	}
+#ifdef DEBUG_SCROLLABLE_IMAGE_CACHE
+        cerr << "ScrollableImageCache: we're left of valid area, adjusted width to " << width << endl;
+#endif
     } else {
 	isLeftOfValidArea = false;
 	width = left + width - (m_left + m_width);
 	left = m_left + m_width;
 	if (width < 0) width = 0;
+#ifdef DEBUG_SCROLLABLE_IMAGE_CACHE
+        cerr << "ScrollableImageCache: we're right of valid area, adjusted left to " << left << ", width to " << width << endl;
+#endif
     }
 }