aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Josh Torres <torres.josh.j@gmail.com>2021-09-05 17:07:08 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-09-06 13:00:37 -0700
commit7e6d9935f13db00ebb980c9d286c7bab0fea8a15 (patch)
tree1031cea13d2c82b420c2af5de77dfc80dea2301c
parent64faa23448f1a18423b306f2b274580568853ccf (diff)
downloadsubsurface-7e6d9935f13db00ebb980c9d286c7bab0fea8a15.tar.gz
core: fix off-by-one causing incorrect profile display
In commit 4724c88 get_plot_details_new was updated to pass an index instead of the entry into plot_string. This means we are passing "i" to plot_string after the final increment of the for loop, instead of getting the entry[i] within the loop before the final increment. This means if we are mousing over the far right of the graph, where the time based break is not hit, we will end up passing an index equal to nr-2 instead of nr-3, which is intended to shave off the final two rows containing data not useful to the display. There are a handful of ways to fix this. This commit intends to be consistent with stylistic choices made elsewhere in the project. Signed-off-by: Josh Torres <torres.josh.j@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/profile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/profile.c b/core/profile.c
index 2db4c54c3..bde706bd0 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -1571,7 +1571,7 @@ int get_plot_details_new(const struct dive *d, const struct plot_info *pi, int t
/* The two first and the two last plot entries do not have useful data */
if (pi->nr <= 4)
return 0;
- for (i = 2; i < pi->nr - 2; i++) {
+ for (i = 2; i < pi->nr - 3; i++) {
if (pi->entry[i].sec >= time)
break;
}