summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-28 19:03:10 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-28 17:03:47 -0700
commitc3306c39f13519441ba2ebd1bbe068fc910e0592 (patch)
treeec686280ff65e29639a3f5b9992ea3029b0cdb9a /qt-ui/divelistview.cpp
parent86d7f6ace06adf13fe5045a217c4f264356a01df (diff)
downloadsubsurface-c3306c39f13519441ba2ebd1bbe068fc910e0592.tar.gz
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>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index a6cca47b6..8f5444804 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -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);