From c9e7528370e4eb4d8836b5deadb9d92ff0f4857c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 4 Nov 2014 14:18:27 -0800 Subject: Change tank editing behavior for multi dive edit Previously we only applied the type of tank (description, volume, working pressure) to all selected dives where the tank description matched. With this patch we also copy the gas mix into all matching cylinders. Additionally this addresses the issue that we should have a separate copy of the cylinder description string for each dive. Fixes #754 Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index d51c21fb0..812760f5a 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -744,14 +744,26 @@ void MainTab::acceptChanges() MODIFY_SELECTED_DIVES( for (int i = 0; i < MAX_CYLINDERS; i++) { if (mydive != cd) { - if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description)) - // only copy the cylinder type, none of the other values - mydive->cylinder[i].type = displayed_dive.cylinder[i].type; + if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description)) { + // if we started out with the same cylinder description make sure that we have the same cylinder type + // and copy the gasmix, but DON'T copy the start and end pressures (those are per dive after all) + if (!same_string(mydive->cylinder[i].type.description, displayed_dive.cylinder[i].type.description)) { + free((void*)mydive->cylinder[i].type.description); + mydive->cylinder[i].type.description = copy_string(displayed_dive.cylinder[i].type.description); + } + mydive->cylinder[i].type.size = displayed_dive.cylinder[i].type.size; + mydive->cylinder[i].type.workingpressure = displayed_dive.cylinder[i].type.workingpressure; + mydive->cylinder[i].gasmix = displayed_dive.cylinder[i].gasmix; + } } } ); - for (int i = 0; i < MAX_CYLINDERS; i++) + for (int i = 0; i < MAX_CYLINDERS; i++) { + // copy the cylinder but make sure we have our own copy of the strings + free((void*)cd->cylinder[i].type.description); cd->cylinder[i] = displayed_dive.cylinder[i]; + cd->cylinder[i].type.description = copy_string(displayed_dive.cylinder[i].type.description); + } do_replot = true; } -- cgit v1.2.3-70-g09d2