displayed_dive vs. current_dive

Dirk Hohndel dirk at hohndel.org
Fri Apr 26 07:04:37 PDT 2019


> On Apr 26, 2019, at 2:42 AM, Robert Helling <helling at lmu.de> wrote:
> 
> Hi,
> 
> I have a question: What is the difference between
> 
> 	displayed_dive and current_dive
> 
> Recently, there have been some PRs in particular from bstoeger that say something along the lines of "Use current_dive instead of displayed_dive in TabDiveInformation”.
> 
> I have to admit that I never really understood the distinction. By only heuristic was that in the planner, current_dive tends to be undefined and thus I always used displayed_dive.
> 
> Maybe somebody could explain when to use which and maybe this could also go as a comment into the source.


This used to be extensively documented in the source, but with all the undo changes, some of this may have gotten lost :-)

Prior to all those undo changes the separation was conceptually rather simple. The current_dive is a pointer to the dive that is currently considered the "main selected dive", i.e. the one that has its profile shown. If only one dive is selected, that's the dive that current_dive points to.
displayed_dive is a dive structure that initially contains a copy of that main selected dive. And all the displaying of dive data, and more importantly, all the editing of dive data used to happen only in the displayed_dive, and was only copied into the dive_table (and therefore into current_dive) once the user accepted the changes.

A lot of this of course has been rendered obsolete due to the undo changes - the exception here are tanks and weights. And those will be converted to the undo code at some point as well. What the semantic difference will be once that is done (or more likely, if we even need the displayed_dive construct any more) is a discussion to be had with Berthold. I believe the plan is to ultimately remove the displayed_dive 

/D


More information about the subsurface mailing list