From 21b7ebbaf002531152977d5a10bf7c74704d28ed Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 22 Sep 2013 07:00:14 -0700 Subject: Fix crash when adding dive to empty dive list Only look up the dive number of a previous dive if there is a previous dive. Reported-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 18d07ef34..b4ee10873 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -421,7 +421,9 @@ void MainTab::acceptChanges() if (editMode == ADD) { // clean up the dive data (get duration, depth information from samples) fixup_dive(current_dive); - if (current_dive == get_dive(dive_table.nr - 1) && get_dive(dive_table.nr - 2)->number) + if (dive_table.nr == 1) + current_dive->number = 1; + else if (current_dive == get_dive(dive_table.nr - 1) && get_dive(dive_table.nr - 2)->number) current_dive->number = get_dive(dive_table.nr - 2)->number + 1; DivePlannerPointsModel::instance()->cancelPlan(); mainWindow()->showProfile(); -- cgit v1.2.3-70-g09d2