Fix crash on adding / removing a dives from add menu

This patch removes some inconsistencies that were happening on the add
dive / cancel actions. a bit of legacy code from the old system was still
in, which made things quite...  EXPLOSIVE.

This fixes restoring the selection only if we have a selection and not
deleting the temporary dive twice.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-05-28 19:03:10 -03:00 committed by Dirk Hohndel
parent 86d7f6ace0
commit c3306c39f1
3 changed files with 22 additions and 21 deletions

View file

@ -29,7 +29,7 @@
#include "../qthelper.h"
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0),
currentOrder(Qt::DescendingOrder), searchBox(this), dontEmitDiveChangedSignal(false)
currentOrder(Qt::DescendingOrder), searchBox(this), dontEmitDiveChangedSignal(false), selectionSaved(false)
{
setItemDelegate(new DiveListDelegate(this));
setUniformRowHeights(true);
@ -147,10 +147,15 @@ void DiveListView::rememberSelection()
if (d)
selectedDives.insert(d->divetrip, get_divenr(d));
}
selectionSaved = true;
}
void DiveListView::restoreSelection()
{
if (!selectionSaved)
return;
selectionSaved = false;
unselectDives();
Q_FOREACH (dive_trip_t *trip, selectedDives.keys()) {
QList<int> divesOnTrip = getDivesInTrip(trip);