mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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 6b2e56e513
.
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>
This commit is contained in:
parent
72bdd506f0
commit
846e1ba53e
2 changed files with 35 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -6,32 +6,56 @@
|
|||
</site>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' date='2013-10-01' time='10:34:00' duration='45:00 min'>
|
||||
<dive number='1' otu='9' cns='5%' date='2013-10-01' time='10:34:00' duration='45:00 min'>
|
||||
<buddy>Dirk</buddy>
|
||||
<suit>wet, 5mm</suit>
|
||||
<divecomputer model='csv' deviceid='ffffffff'>
|
||||
<divecomputer model='csv' last-manual-time='45:00 min' deviceid='ffffffff'>
|
||||
<depth max='18.0 m' mean='16.0 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
<sample time='2:00 min' depth='18.0 m' />
|
||||
<sample time='38:31 min' depth='18.0 m' />
|
||||
<sample time='39:51 min' depth='5.94 m' />
|
||||
<sample time='44:20 min' depth='5.94 m' />
|
||||
<sample time='45:00 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='2' date='2013-10-01' time='12:13:00' duration='41:00 min'>
|
||||
<dive number='2' otu='5' cns='7%' date='2013-10-01' time='12:13:00' duration='41:00 min'>
|
||||
<buddy>Linus</buddy>
|
||||
<suit>wet, shorty, 3mm</suit>
|
||||
<divecomputer model='csv' deviceid='ffffffff'>
|
||||
<divecomputer model='csv' last-manual-time='41:00 min' deviceid='ffffffff'>
|
||||
<depth max='16.2 m' mean='13.5 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
<sample time='1:48 min' depth='16.2 m' />
|
||||
<sample time='31:41 min' depth='16.2 m' />
|
||||
<sample time='32:53 min' depth='5.346 m' />
|
||||
<sample time='40:24 min' depth='5.346 m' />
|
||||
<sample time='41:00 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='3' date='2014-10-01' time='10:02:00' duration='48:00 min'>
|
||||
<buddy>Tomaz</buddy>
|
||||
<suit>none</suit>
|
||||
<divecomputer model='csv' deviceid='ffffffff'>
|
||||
<divecomputer model='csv' last-manual-time='48:00 min' deviceid='ffffffff'>
|
||||
<depth max='13.3 m' mean='11.5 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
<sample time='1:29 min' depth='13.3 m' />
|
||||
<sample time='39:02 min' depth='13.3 m' />
|
||||
<sample time='40:02 min' depth='4.389 m' />
|
||||
<sample time='47:31 min' depth='4.389 m' />
|
||||
<sample time='48:00 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='4' date='2014-10-01' time='14:19:00' duration='34:00 min'>
|
||||
<dive number='4' otu='13' cns='5%' date='2014-10-01' time='14:19:00' duration='34:00 min'>
|
||||
<buddy>Don</buddy>
|
||||
<suit>dry, Whites Fusion</suit>
|
||||
<divecomputer model='csv' deviceid='ffffffff'>
|
||||
<divecomputer model='csv' last-manual-time='34:00 min' deviceid='ffffffff'>
|
||||
<depth max='24.9 m' mean='20.1 m' />
|
||||
<sample time='0:00 min' depth='0.0 m' />
|
||||
<sample time='2:46 min' depth='24.9 m' />
|
||||
<sample time='25:35 min' depth='24.9 m' />
|
||||
<sample time='27:26 min' depth='8.217 m' />
|
||||
<sample time='33:05 min' depth='8.217 m' />
|
||||
<sample time='34:00 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='417' otu='138' cns='54%' divesiteid='deadbeef' date='2015-05-23' time='13:23:00' duration='100:00 min'>
|
||||
|
|
Loading…
Reference in a new issue