Dive planner: remember the selection before new dives get handled

On an empty dive list we would remember the new dive (which gets
auto-selected since it's the only dive) and then crash when we try to
restore that selection after cancel (in which case that new dive is gone).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-05-28 05:03:14 -07:00
parent 424d38e0c1
commit f8a773b37f

View file

@ -378,9 +378,9 @@ void MainWindow::createFakeDiveForAddAndPlan()
dive->longitude.udeg = 0;
record_dive(dive);
// select this new dive (but remember the old selection
ui.ListWidget->reload(DiveTripModel::CURRENT);
ui.ListWidget->rememberSelection();
ui.ListWidget->unselectDives();
ui.ListWidget->reload(DiveTripModel::CURRENT);
ui.ListWidget->selectDives(QList<int>() << dive_table.nr - 1);
ui.InfoWidget->updateDiveInfo(selected_dive);
}