Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 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 | ab2cafd3a7cb |
children | 13d03ae0c6e0 |
comparison
equal
deleted
inserted
replaced
1342:ed6400d5b571 | 1343:5f3e374746b6 |
---|---|
621 mixingChannels || mergingChannels, | 621 mixingChannels || mergingChannels, |
622 frame0, frame1, | 622 frame0, frame1, |
623 v->getZoomLevel().level, ranges); | 623 v->getZoomLevel().level, ranges); |
624 } | 624 } |
625 | 625 |
626 for (int ch = minChannel; ch <= maxChannel; ++ch) { | 626 if (!ranges.empty()) { |
627 paintChannel(v, paint, rect, ch, ranges, blockSize, frame0, frame1); | 627 for (int ch = minChannel; ch <= maxChannel; ++ch) { |
628 paintChannel(v, paint, rect, ch, ranges, blockSize, | |
629 frame0, frame1); | |
630 } | |
628 } | 631 } |
629 | 632 |
630 if (m_middleLineHeight != 0.5) { | 633 if (m_middleLineHeight != 0.5) { |
631 paint->restore(); | 634 paint->restore(); |
632 } | 635 } |
669 } | 672 } |
670 } | 673 } |
671 | 674 |
672 void | 675 void |
673 WaveformLayer::getOversampledRanges(int minChannel, int maxChannel, | 676 WaveformLayer::getOversampledRanges(int minChannel, int maxChannel, |
674 bool mixingOrMerging, | 677 bool /* mixingOrMerging */, |
675 sv_frame_t frame0, sv_frame_t frame1, | 678 sv_frame_t frame0, sv_frame_t frame1, |
676 int oversampleBy, RangeVec &ranges) | 679 int oversampleBy, RangeVec &ranges) |
677 const | 680 const |
678 { | 681 { |
679 // These frame values, tail length, etc variables are at the model | 682 // These frame values, tail length, etc variables are at the model |
680 // sample rate, not the oversampled rate | 683 // sample rate, not the oversampled rate |
681 | 684 |
682 sv_frame_t tail = 16; | 685 sv_frame_t tail = 16; |
683 sv_frame_t leftTail = tail, rightTail = tail; | |
684 sv_frame_t startFrame = m_model->getStartFrame(); | 686 sv_frame_t startFrame = m_model->getStartFrame(); |
685 sv_frame_t endFrame = m_model->getEndFrame(); | 687 sv_frame_t endFrame = m_model->getEndFrame(); |
686 | 688 |
687 sv_frame_t rf0 = frame0 - tail; | 689 sv_frame_t rf0 = frame0 - tail; |
688 if (rf0 < startFrame) { | 690 if (rf0 < startFrame) { |
689 leftTail = frame0 - startFrame; | |
690 rf0 = 0; | 691 rf0 = 0; |
691 } | 692 } |
692 | 693 |
693 sv_frame_t rf1 = frame1 + tail; | 694 sv_frame_t rf1 = frame1 + tail; |
694 if (rf1 >= endFrame) { | 695 if (rf1 >= endFrame) { |
695 rightTail = endFrame - 1 - frame1; | |
696 rf1 = endFrame - 1; | 696 rf1 = endFrame - 1; |
697 } | 697 } |
698 if (rf1 <= rf0) { | 698 if (rf1 <= rf0) { |
699 SVCERR << "WARNING: getOversampledRanges: rf1 (" << rf1 << ") <= rf0 (" | 699 SVCERR << "WARNING: getOversampledRanges: rf1 (" << rf1 << ") <= rf0 (" |
700 << rf0 << ")" << endl; | 700 << rf0 << ")" << endl; |
1046 QPainter *paint, | 1046 QPainter *paint, |
1047 QRect rect, | 1047 QRect rect, |
1048 int ch) const | 1048 int ch) const |
1049 { | 1049 { |
1050 int x0 = rect.left(); | 1050 int x0 = rect.left(); |
1051 int y0 = rect.top(); | |
1052 | |
1053 int x1 = rect.right(); | 1051 int x1 = rect.right(); |
1054 int y1 = rect.bottom(); | |
1055 | 1052 |
1056 int n = 10; | 1053 int n = 10; |
1057 int py = -1; | 1054 int py = -1; |
1058 | 1055 |
1059 double gain = m_effectiveGains[ch]; | 1056 double gain = m_effectiveGains[ch]; |