X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecodetrace.cpp;h=71fbaa85c613d29dab29400edc5fe3d17c76c8c5;hp=94ef5f9a4a1364a9fac3c843cbb84173f3228031;hb=99029fda9b736c04eb2c22c92ca5086fb948bc13;hpb=2a56e4485a97c1d3e679325ec5413039d7a0c06c diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 94ef5f9a..71fbaa85 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -556,9 +556,15 @@ int DecodeTrace::get_row_at_point(const QPoint &point) if (!row_height_) return -1; - const int row = (point.y() - get_visual_y() + row_height_ / 2) / - row_height_; - if (row < 0 || row >= (int)visible_rows_.size()) + const int y = (point.y() - get_visual_y() + row_height_ / 2); + + /* Integer divison of (x-1)/x would yield 0, so we check for this. */ + if (y < 0) + return -1; + + const int row = y / row_height_; + + if (row >= (int)visible_rows_.size()) return -1; return row; @@ -587,11 +593,6 @@ const QString DecodeTrace::get_annotation_at_point(const QPoint &point) QString() : annotations[0].annotations().front(); } -void DecodeTrace::hide_hover_annotation() -{ - QToolTip::hideText(); -} - void DecodeTrace::hover_point_changed() { assert(owner_); @@ -605,7 +606,7 @@ void DecodeTrace::hover_point_changed() assert(view); if (!row_height_ || ann.isEmpty()) { - hide_hover_annotation(); + QToolTip::hideText(); return; } @@ -626,7 +627,7 @@ void DecodeTrace::hover_point_changed() hp.setY(get_visual_y() - (row_height_ / 2) + (hover_row * row_height_) - - row_height_ - text_size.height()); + row_height_ - text_size.height() - padding); QToolTip::showText(view->viewport()->mapToGlobal(hp), ann); }