mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Always make sure the planner starts with at least one cylinder
void DivePlannerPointsModel::setupCylinders() in diveplannermodel.cpp handles setting up cylinders for the planner. If there is a current dive, cylinders form that dive are copied. Otherwise the default cylinder is added and lacking that a standard size cylinder. If the current dive does not have any cylinders, we could end up without cylinders. This patch adds a test for this case and delegates to the other two sources of a cylinder in that case. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d0d8c12c8c
commit
27f706064f
1 changed files with 5 additions and 1 deletions
|
@ -115,12 +115,16 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
|||
// setup the cylinder widget accordingly
|
||||
void DivePlannerPointsModel::setupCylinders()
|
||||
{
|
||||
int i;
|
||||
if (mode == PLAN && current_dive) {
|
||||
// take the displayed cylinders from the selected dive as starting point
|
||||
CylindersModel::instance()->copyFromDive(current_dive);
|
||||
copy_cylinders(current_dive, &displayed_dive, !prefs.display_unused_tanks);
|
||||
reset_cylinders(&displayed_dive, true);
|
||||
return;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++)
|
||||
if (!cylinder_none(&(displayed_dive.cylinder[i])))
|
||||
return; // We have at least one cylinder
|
||||
}
|
||||
if (!same_string(prefs.default_cylinder, "")) {
|
||||
fill_default_cylinder(&displayed_dive.cylinder[0]);
|
||||
|
|
Loading…
Add table
Reference in a new issue