diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-09-22 07:00:14 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-09-22 07:00:14 -0700 |
commit | 21b7ebbaf002531152977d5a10bf7c74704d28ed (patch) | |
tree | 7103174522abbf97f95f0e38f1ec5f84e2b16258 /qt-ui | |
parent | 5935f372ab61c4dd7772990fe6e5bfcd214f6ace (diff) | |
download | subsurface-21b7ebbaf002531152977d5a10bf7c74704d28ed.tar.gz |
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 <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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(); |