X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fanalogsignal.cpp;h=cddf59c15059cdda26a209b4781032f73fdd9bce;hb=00c518d66a61f28609b0eeddd0ce375d0002da94;hp=2c5c82a9d1d18c5609d9d7965d2a10f35a6e2149;hpb=d37ff80d1d8ef4d63094c07f8009742a356922bb;p=pulseview.git diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index 2c5c82a..cddf59c 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ using std::max; using std::make_pair; using std::min; using std::numeric_limits; +using std::out_of_range; using std::pair; using std::placeholders::_1; using std::shared_ptr; @@ -225,8 +227,10 @@ void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp) // Draw high/neutral/low areas if (thresholds.size() == 2) { - const double thr_lo = visual_y - thresholds[0] * scale_; - const double thr_hi = visual_y - thresholds[1] * scale_; + int thr_lo = visual_y - thresholds[0] * scale_; + int thr_hi = visual_y - thresholds[1] * scale_; + thr_lo = min(max(thr_lo, top), btm); + thr_hi = min(max(thr_hi, top), btm); p.fillRect(QRectF(pp.left(), top, pp.width(), thr_hi - top), QBrush(ThresholdColorHi)); @@ -235,7 +239,8 @@ void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp) p.fillRect(QRectF(pp.left(), thr_lo, pp.width(), btm - thr_lo), QBrush(ThresholdColorLo)); } else { - const double thr = visual_y - thresholds[0] * scale_; + int thr = visual_y - thresholds[0] * scale_; + thr = min(max(thr, top), btm); p.fillRect(QRectF(pp.left(), top, pp.width(), thr - top), QBrush(ThresholdColorHi)); @@ -268,8 +273,13 @@ void AnalogSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp) if (segments.empty()) return; - const shared_ptr &segment = - segments.front(); + shared_ptr segment; + try { + segment = segments.at(current_segment_); + } catch (out_of_range) { + qDebug() << "Current analog segment out of range for signal" << base_->name(); + return; + } const double pixels_offset = pp.pixels_offset(); const double samplerate = max(1.0, segment->samplerate()); @@ -535,8 +545,13 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp) if (segments.empty()) return; - const shared_ptr &segment = - segments.front(); + shared_ptr segment; + try { + segment = segments.at(current_segment_); + } catch (out_of_range) { + qDebug() << "Current logic segment out of range for signal" << base_->name(); + return; + } double samplerate = segment->samplerate();