summaryrefslogtreecommitdiffstats
path: root/qt-models/diveimportedmodel.cpp
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-05-28 14:02:26 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 08:57:04 -0700
commit8d42d33f93c2eec54013c984cd902f094eb9d25f (patch)
tree09beae8d0e7e61ecee9e37fa774e3a16e52e5672 /qt-models/diveimportedmodel.cpp
parent3f0d21046e92701de200a00f12bde20a7ad3a55c (diff)
downloadsubsurface-8d42d33f93c2eec54013c984cd902f094eb9d25f.tar.gz
mobile: Prevent tripping assert on empty BT download
When (with mobile on desktop) loading from DC is called and the dive computer to connect to is not in download mode, the repopulate() function is called with an empty dive table. This trips the assert (obviously, debug compile only) in DiveImportedModel::setImportedDivesIndexes(). This simple fix makes things just more robust. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'qt-models/diveimportedmodel.cpp')
-rw-r--r--qt-models/diveimportedmodel.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp
index c1f4f7525..1b8b5a897 100644
--- a/qt-models/diveimportedmodel.cpp
+++ b/qt-models/diveimportedmodel.cpp
@@ -140,7 +140,10 @@ void DiveImportedModel::setImportedDivesIndexes(int first, int last)
void DiveImportedModel::repopulate()
{
- setImportedDivesIndexes(0, diveTable->nr-1);
+ if (diveTable->nr)
+ setImportedDivesIndexes(0, diveTable->nr-1);
+ else
+ setImportedDivesIndexes(0, 0);
}
void DiveImportedModel::recordDives()