summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-04 14:18:27 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-04 15:05:16 -0800
commitc9e7528370e4eb4d8836b5deadb9d92ff0f4857c (patch)
treed587cadc754840331622e732b2e465590776e099 /qt-ui/maintab.cpp
parent54692fb81431fb3366a239a6dcbf3c52f9d34520 (diff)
downloadsubsurface-c9e7528370e4eb4d8836b5deadb9d92ff0f4857c.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp20
1 files changed, 16 insertions, 4 deletions
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;
}