From 573d40b64bee1655a65d4bbe3d784046eb7a0ccf Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Sat, 27 Apr 2024 22:13:03 +0800 Subject: [PATCH] fix: the cursor time is overflow on dso mode --- DSView/pv/view/ruler.cpp | 11 +++++++++-- DSView/pv/view/view.cpp | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/DSView/pv/view/ruler.cpp b/DSView/pv/view/ruler.cpp index 61b9353d..8b889f6c 100644 --- a/DSView/pv/view/ruler.cpp +++ b/DSView/pv/view/ruler.cpp @@ -174,10 +174,17 @@ QString Ruler::format_time(double t) QString Ruler::format_real_time(uint64_t delta_index, uint64_t sample_rate) { - uint64_t delta_time = std::pow(10, 12) / sample_rate * delta_index; + double v1 = (double)std::pow(10, 12) / (double)sample_rate; + double delta_time_double = v1 * delta_index; + uint64_t delta_time = v1 * delta_index; - if (delta_time == 0) + if (delta_time_double > UINT64_MAX){ + return "INF"; + } + + if (delta_time == 0) { return "0"; + } int zero = 0; int prefix = (int)floor(log10(delta_time)); diff --git a/DSView/pv/view/view.cpp b/DSView/pv/view/view.cpp index bd44b325..c35f8f86 100644 --- a/DSView/pv/view/view.cpp +++ b/DSView/pv/view/view.cpp @@ -1135,7 +1135,9 @@ QString View::get_measure(QString option) QString View::get_cm_time(int index) { - return _ruler->format_real_time(get_cursor_samples(index), _session->cur_snap_samplerate()); + uint64_t sampleIndex = get_cursor_samples(index); + uint64_t sampleRate = _session->cur_snap_samplerate(); + return _ruler->format_real_time(sampleIndex, sampleRate); } QString View::get_cm_delta(int index1, int index2)