projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3a54cb6
)
DecodeTrace: Correct row calculation/tooltip position for row 0
author
Soeren Apel
<soeren@apelpie.net>
Fri, 12 Dec 2014 16:32:06 +0000
(17:32 +0100)
committer
Soeren Apel
<soeren@apelpie.net>
Fri, 12 Dec 2014 16:32:06 +0000
(17:32 +0100)
pv/view/decodetrace.cpp
patch
|
blob
|
history
diff --git
a/pv/view/decodetrace.cpp
b/pv/view/decodetrace.cpp
index 0a2afbfa67f4e16474cb9330e0800f0d361ee03f..71fbaa85c613d29dab29400edc5fe3d17c76c8c5 100644
(file)
--- 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;
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;
return -1;
return row;
@@
-621,7
+627,7
@@
void DecodeTrace::hover_point_changed()
hp.setY(get_visual_y() - (row_height_ / 2) +
(hover_row * row_height_) -
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);
}
QToolTip::showText(view->viewport()->mapToGlobal(hp), ann);
}