From c0ac73a478c5407467019d61ed2536bef90edd62 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Thu, 8 Oct 2015 18:59:37 +0300 Subject: Fix a crash when editing manually added dive I have manually added dives from an ancient version of Subsurface. Trying to edit these caused Subsurface to crash due to comparison of string of dc.model that did not exist (to a static string). And further down the execution path we were crashing as there were no samples associated with the dive. See #941 Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- qt-models/diveplannermodel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qt-models') diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 49fc50229..b5db3f07e 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -78,7 +78,12 @@ void DivePlannerPointsModel::loadFromDive(dive *d) // if yes then the first sample should be marked // if it is we only add the manually entered samples as waypoints to the diveplan // otherwise we have to add all of them - bool hasMarkedSamples = d->dc.sample[0].manually_entered; + + bool hasMarkedSamples = false; + + if (d->dc.samples) + hasMarkedSamples = d->dc.sample[0].manually_entered; + // if this dive has more than 100 samples (so it is probably a logged dive), // average samples so we end up with a total of 100 samples. int plansamples = d->dc.samples <= 100 ? d->dc.samples : 100; -- cgit v1.2.3-70-g09d2