Skip to content

Commit

Permalink
timing.ui: no tooltip when no data is hovered
Browse files Browse the repository at this point in the history
The binary search here will return a negative number if and only if
there is no value found. If there is no value found, that means the
mouse is hovering a section of the graph where there is no data. In that
case, no tooltip should be displayed.

To test that, the user should use the Density Viewer of any analysis
and hover on the leftmost side of the graph. It might be a quite small
area, but zooming on the leftmost side of the view can make that error
appear often.

The previous behaviour ends up throwing an error, because if the binary
search returns -1, the calculated index is -1 which is out of bounds.

Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
Change-Id: Ic7f312babc31367af3182ff14f235e17e5205b51
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/203431
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-by: Marco Miller <marco.miller@ericsson.com>
  • Loading branch information
arfio authored and marco-miller committed Aug 3, 2023
1 parent 46e8bd3 commit a66a84e
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -64,7 +64,7 @@ public void fill(Control control, MouseEvent event, Point pt) {
double coords = xAxis.getDataCoordinate(event.x);
int index = Arrays.binarySearch(xValues, coords);
if (index < 0) {
index = -index - 2;
return;
}
double[] ySeries = ySeriesProvider.getYSeries();
long y = Math.round(ySeries[index]);
Expand Down Expand Up @@ -116,4 +116,4 @@ public TmfAbstractToolTipHandler getTooltipHandler() {
public SimpleTooltipProvider(AbstractSegmentStoreDensityViewer densityViewer) {
super(densityViewer);
}
}
}

0 comments on commit a66a84e

Please sign in to comment.