# HG changeset patch # User Chris Cannam # Date 1172769170 0 # Node ID 8520b79181046fa820cc92a1305adb8598d874d5 # Parent df791d8c8f583fc260a1df484cf86c72bf6045d5 * Fix overzealous cacheing in waveform layer that was leading to inaccurate positioning of view rects & playback pointer on overview widget sometimes diff -r df791d8c8f58 -r 8520b7918104 layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Thu Mar 01 15:35:27 2007 +0000 +++ b/layer/WaveformLayer.cpp Thu Mar 01 17:12:50 2007 +0000 @@ -466,20 +466,30 @@ if (m_aggressive) { +#ifdef DEBUG_WAVEFORM_PAINT + std::cerr << "WaveformLayer::paint: aggressive is true" << std::endl; +#endif + if (m_cacheValid && (zoomLevel != m_cacheZoomLevel)) { m_cacheValid = false; } + if (!m_cache || m_cache->width() != w || m_cache->height() != h) { +#ifdef DEBUG_WAVEFORM_PAINT + if (m_cache) { + std::cerr << "WaveformLayer::paint: cache size " << m_cache->width() << "x" << m_cache->height() << " differs from view size " << w << "x" << h << ": regenerating aggressive cache" << std::endl; + } +#endif + delete m_cache; + m_cache = new QPixmap(w, h); + m_cacheValid = false; + } + if (m_cacheValid) { viewPainter.drawPixmap(rect, *m_cache, rect); return; } - if (!m_cache || m_cache->width() != w || m_cache->height() != h) { - delete m_cache; - m_cache = new QPixmap(w, h); - } - paint = new QPainter(m_cache); paint->setPen(Qt::NoPen); diff -r df791d8c8f58 -r 8520b7918104 view/Overview.cpp --- a/view/Overview.cpp Thu Mar 01 15:35:27 2007 +0000 +++ b/view/Overview.cpp Thu Mar 01 17:12:50 2007 +0000 @@ -101,6 +101,8 @@ { // Recalculate zoom in case the size of the widget has changed. +// std::cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << std::endl; + size_t startFrame = getModelsStartFrame(); size_t frameCount = getModelsEndFrame() - getModelsStartFrame(); int zoomLevel = frameCount / width(); @@ -116,7 +118,10 @@ centreFrame = (startFrame + getModelsEndFrame())/2; } if (centreFrame != m_centreFrame) { +// std::cerr << "Overview::paintEvent: Centre frame changed from " +// << m_centreFrame << " to " << centreFrame << " and thus start frame from " << getStartFrame(); m_centreFrame = centreFrame; +// std::cerr << " to " << getStartFrame() << std::endl; emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); }