Be more careful about unit changes

When we change units, we need to flush any currently active dive
information in the old units, and then carefully reload it in the new
units.

Otherwise crazy stuff happens - like having current cylinder working
pressure values that are in PSI because that *used* to be the output
unit, but then interpreting those values as BAR, because we changed the
units.

Also, since we now properly import working pressure from Diving Log,
stop importing the (useless) cylinder description.  The Diving Log
cylinder descriptions are things like "Alu" or "Steel".  We're better
off just making up our own.

Finally, since Diving Log has cylinder size in metric, make sure that we
do the "match standard cylinder sizes" *after* we've done all the
cylinder size conversions to proper units.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2011-09-11 12:53:59 -07:00
parent 61d0aa10e1
commit 0c4e1697db
5 changed files with 15 additions and 12 deletions

4
main.c
View file

@ -98,9 +98,9 @@ void update_dive(struct dive *new_dive)
if (old_dive) {
flush_dive_info_changes(old_dive);
flush_dive_equipment_changes(old_dive);
buffered_dive = new_dive;
}
if (new_dive) {
buffered_dive = new_dive;
show_dive_info(new_dive);
show_dive_equipment(new_dive);
}
@ -312,6 +312,8 @@ static void unit_dialog(GtkWidget *w, gpointer data)
gtk_widget_show_all(dialog);
result = gtk_dialog_run(GTK_DIALOG(dialog));
if (result == GTK_RESPONSE_ACCEPT) {
/* Make sure to flush any modified old dive data with old units */
update_dive(NULL);
output_units = menu_units;
update_dive_list_units(&dive_list);
repaint_dive();