aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-07-15 09:14:31 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-07-23 11:30:17 -0700
commit846e1ba53e32aaeae22b72d4a7843700627f2b27 (patch)
tree4843358441c48c37658da6826f08e983602391c8 /core
parent72bdd506f07d6a2cc9652efe0353a85d9b8e481a (diff)
downloadsubsurface-846e1ba53e32aaeae22b72d4a7843700627f2b27.tar.gz
core: always create a fake profile if there are no samples
Before making the cylinder-table dynamic, dives always had at least one cylinger. When such a dive is displayed, the TabDiveInformation class calls per_cylinder_mean_depth(). If there are no samples, this function generates a "fake profile" with fake_dc(). Thus, effectively dives always had samples once the user was displaying them. When the cylinder-table was made dynamic, dives without cylinders were supported. This can notably happen, when importing from CSV (this could actually be a bug). per_cylinder_mean_depth() exits early in that case and doesn't create a fake profile. This lead to crashes of the profile-widget, which were fixed in 6b2e56e5131. Non-sample dives were now shown with the Subsurface-logo. To restore the previous behavior, genarate a fake profile for sample-less dives in fixup_dive(), which is called anytime a dive is loaded or imported. This seems to have been the intention anyway and this worked only "by chance". This will make a few fake_dc() calls obsolete, but so be it. Since fake profiles are now generated on loading, the parse-tests need to be fixed to account for that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/dive.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/dive.c b/core/dive.c
index a4a47ab90..571f244df 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1246,6 +1246,10 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
/* Fixup CCR / PSCR dives with o2sensor values, but without no_o2sensors */
fixup_no_o2sensors(dc);
+
+ /* If there are no samples, generate a fake profile based on depth and time */
+ if (!dc->samples)
+ fake_dc(dc);
}
struct dive *fixup_dive(struct dive *dive)