From 37794e2e236fbbc4a1a55724df3bb1ef160a9ae7 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 17 Mar 2014 08:19:09 -0700 Subject: Be more careful about dive computer selection The selection logic was a bit random: some places would return NULL if the dive computer index was out of range, others would return the primary dive computer, and actually moving between dive computers would just blindly increment and decrement the number. This always selects the primary computer if the index is out of bounds, and makes sure we stay in bound when switching beteen dive computers (but switching between dives can then turn an in-bound number into an out-of-bounds one) Fixes #464 Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui/diveplanner.cpp') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 27eedb586..476812080 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1472,7 +1472,7 @@ void DivePlannerPointsModel::createPlan() plan(&diveplan, &cache, &tempDive, isPlanner()); copy_cylinders(stagingDive, tempDive); int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS]; - per_cylinder_mean_depth(tempDive, select_dc(&tempDive->dc), mean, duration); + per_cylinder_mean_depth(tempDive, select_dc(tempDive), mean, duration); for (int i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = tempDive->cylinder + i; if (cylinder_none(cyl)) -- cgit v1.2.3-70-g09d2