From a422957cd6525b9753cafacfafdf1f3eef66870d Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Thu, 19 Oct 2017 15:29:59 +0200 Subject: Use displayed_dc instead of current_dc current_dc is a macro that determines the dive computer based on the current dive number. When the planner is started from an emtpy dive list, the dive number ends up being -1 and that doesn't produce a valid dive computer. Use the divecomputer of the displayed_dive instead. This is done via a macro that can also be used in two other places. Without this patch, the planner crashed when called on an empty dive list. Signed-off-by: Robert C. Helling --- core/dive.h | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/dive.h b/core/dive.h index 8e862f691..b02ce5f6c 100644 --- a/core/dive.h +++ b/core/dive.h @@ -549,6 +549,7 @@ extern int selected_dive; extern unsigned int dc_number; #define current_dive (get_dive(selected_dive)) #define current_dc (get_dive_dc(current_dive, dc_number)) +#define displayed_dc (get_dive_dc(&displayed_dive, dc_number)) static inline struct dive *get_dive(int nr) { -- cgit v1.2.3-70-g09d2