dive planner fixes [was: Re: source code may be getting a bit intimidating]

Linus Torvalds torvalds at linux-foundation.org
Mon Jan 7 13:06:33 PST 2013

On Mon, Jan 7, 2013 at 12:03 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
> Don't use this. It's better done in create_dive_from_plan() instead.
> I'll have a new patch soon.

Ok, "soon" turned out to be longer than I thought.

One main reason for the gas confusion was that the gas widget didn't
get the "index", so the callback always updated the first dive plan
entry. *That* caused lots of confusion.

Another reason was that the "ok" button re-did the dive planning, but
did it differently from the incremental one, and it wasn't better. It
turns out that it's better to just do the same "plan()" function
directly, rather to re-implement the "let's add the segments"

This actually makes things work for me. Now, the planning seems to
always want to switch back to gas index 1, so if I do a plan that
looks like

  150 +10 20/30
  150 +5
  100 +5
  100 +1 40

it does generate the proper switch to EAN40 at the 21-minute mark, but
then the planning code decides to switch back at the next entry. No
big deal.

Anyway, it does seem to work, and this patch actually removes way more
lines of code than it adds, simply because it reuses the planning (and
because it removes the unnecessary strdup/free patterns).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 11283 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130107/af1f8705/attachment.obj>

More information about the subsurface mailing list