]> sigrok.org Git - pulseview.git/commitdiff
MainBar: Properly limit the lower value of the sample range
authorSoeren Apel <redacted>
Fri, 10 Feb 2017 19:22:51 +0000 (20:22 +0100)
committerUwe Hermann <redacted>
Wed, 15 Feb 2017 11:12:31 +0000 (12:12 +0100)
This fixes bug #890.

pv/toolbars/mainbar.cpp

index 9bebda80061c1d29a5216a4188f2a09c3a911ce2..188786f1f1691019499e402a0c2ce425774d1fba 100644 (file)
@@ -611,9 +611,10 @@ void MainBar::export_file(shared_ptr<OutputFormat> format,
                const pv::util::Timestamp& start_time = trace_view->cursors()->first()->time();
                const pv::util::Timestamp& end_time = trace_view->cursors()->second()->time();
 
-               const uint64_t start_sample =
-                       std::max((double)0, start_time.convert_to<double>() * samplerate);
-               const uint64_t end_sample = end_time.convert_to<double>() * samplerate;
+               const uint64_t start_sample = (uint64_t)std::max(
+                       (double)0, start_time.convert_to<double>() * samplerate);
+               const uint64_t end_sample = (uint64_t)std::max(
+                       (double)0, end_time.convert_to<double>() * samplerate);
 
                sample_range = std::make_pair(start_sample, end_sample);
        } else {