]> sigrok.org Git - pulseview.git/commitdiff
Fix #1125 by adding a missing typecast
authorSoeren Apel <redacted>
Thu, 8 Mar 2018 23:28:42 +0000 (00:28 +0100)
committerSoeren Apel <redacted>
Mon, 12 Mar 2018 14:58:14 +0000 (15:58 +0100)
Without this typecast, the return type of get_sample_count() is
a uint64_t, which doesn't go well when it's 0 and we subtract 1
from it. Assigning the result of this underflow to an int64_t
doesn't help, it's too late.

pv/views/trace/analogsignal.cpp
pv/views/trace/logicsignal.cpp

index bbc23fb70074bace6adc25e304d70d50583de3dd..11a73068b25c13bb7724971a57aad8775796e38b 100644 (file)
@@ -285,7 +285,7 @@ void AnalogSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp)
                const double pixels_offset = pp.pixels_offset();
                const double samplerate = max(1.0, segment->samplerate());
                const pv::util::Timestamp& start_time = segment->start_time();
-               const int64_t last_sample = segment->get_sample_count() - 1;
+               const int64_t last_sample = (int64_t)segment->get_sample_count() - 1;
                const double samples_per_pixel = samplerate * pp.scale();
                const pv::util::Timestamp start = samplerate * (pp.offset() - start_time);
                const pv::util::Timestamp end = start + samples_per_pixel * pp.width();
@@ -552,7 +552,7 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp)
 
        const double pixels_offset = pp.pixels_offset();
        const pv::util::Timestamp& start_time = segment->start_time();
-       const int64_t last_sample = segment->get_sample_count() - 1;
+       const int64_t last_sample = (int64_t)segment->get_sample_count() - 1;
        const double samples_per_pixel = samplerate * pp.scale();
        const double pixels_per_sample = 1 / samples_per_pixel;
        const pv::util::Timestamp start = samplerate * (pp.offset() - start_time);
index 99900941918b9b8058fce31b52f68ddd8275ac8b..1f25890dd5b7a3e11f83afd909a053e1d79c8990 100644 (file)
@@ -204,7 +204,7 @@ void LogicSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp)
 
        const double pixels_offset = pp.pixels_offset();
        const pv::util::Timestamp& start_time = segment->start_time();
-       const int64_t last_sample = segment->get_sample_count() - 1;
+       const int64_t last_sample = (int64_t)segment->get_sample_count() - 1;
        const double samples_per_pixel = samplerate * pp.scale();
        const double pixels_per_sample = 1 / samples_per_pixel;
        const pv::util::Timestamp start = samplerate * (pp.offset() - start_time);