Mercurial > hg > svgui
changeset 1343:5f3e374746b6 zoom
Fix crash when scrolling beyond end of waveform (+ fix compiler warnings)
author | Chris Cannam |
---|---|
date | Thu, 27 Sep 2018 16:20:58 +0100 |
parents | ed6400d5b571 |
children | 13d03ae0c6e0 |
files | layer/WaveformLayer.cpp view/View.cpp |
diffstat | 2 files changed, 8 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp Thu Sep 27 15:54:02 2018 +0100 +++ b/layer/WaveformLayer.cpp Thu Sep 27 16:20:58 2018 +0100 @@ -623,8 +623,11 @@ v->getZoomLevel().level, ranges); } - for (int ch = minChannel; ch <= maxChannel; ++ch) { - paintChannel(v, paint, rect, ch, ranges, blockSize, frame0, frame1); + if (!ranges.empty()) { + for (int ch = minChannel; ch <= maxChannel; ++ch) { + paintChannel(v, paint, rect, ch, ranges, blockSize, + frame0, frame1); + } } if (m_middleLineHeight != 0.5) { @@ -671,7 +674,7 @@ void WaveformLayer::getOversampledRanges(int minChannel, int maxChannel, - bool mixingOrMerging, + bool /* mixingOrMerging */, sv_frame_t frame0, sv_frame_t frame1, int oversampleBy, RangeVec &ranges) const @@ -680,19 +683,16 @@ // sample rate, not the oversampled rate sv_frame_t tail = 16; - sv_frame_t leftTail = tail, rightTail = tail; sv_frame_t startFrame = m_model->getStartFrame(); sv_frame_t endFrame = m_model->getEndFrame(); sv_frame_t rf0 = frame0 - tail; if (rf0 < startFrame) { - leftTail = frame0 - startFrame; rf0 = 0; } sv_frame_t rf1 = frame1 + tail; if (rf1 >= endFrame) { - rightTail = endFrame - 1 - frame1; rf1 = endFrame - 1; } if (rf1 <= rf0) { @@ -1048,10 +1048,7 @@ int ch) const { int x0 = rect.left(); - int y0 = rect.top(); - int x1 = rect.right(); - int y1 = rect.bottom(); int n = 10; int py = -1;
--- a/view/View.cpp Thu Sep 27 15:54:02 2018 +0100 +++ b/view/View.cpp Thu Sep 27 16:20:58 2018 +0100 @@ -390,12 +390,12 @@ int diff, result; if (m_zoomLevel.zone == ZoomLevel::FramesPerPixel) { - diff = fdiff / level; + diff = int(fdiff / level); if ((fdiff < 0) && ((fdiff % level) != 0)) { --diff; // round to the left } } else { - diff = fdiff * level; + diff = int(fdiff * level); } result = int(diff + (width()/2));