aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-17 10:41:02 +0000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-17 10:41:02 +0000
commit7196176fa02d80f1690d5d486619c24a1e57a0c4 (patch)
tree4cc30717ac9324b0dec048d5299e50bfc28111b9 /qt-ui/maintab.cpp
parentac9c2ba5440c987a4fbda1564d0a2ab7598e48b9 (diff)
downloadsubsurface-7196176fa02d80f1690d5d486619c24a1e57a0c4.tar.gz
Correctly copy weight systems on edit
We copied the string pointers instead of copying the strings. Once those got freed, things went downhill. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 514d9567e..8ebf1504c 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -781,12 +781,16 @@ void MainTab::acceptChanges()
mark_divelist_changed(true);
MODIFY_SELECTED_DIVES(
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
- if (mydive != cd && (copyPaste || same_string(mydive->weightsystem[i].description, cd->weightsystem[i].description)))
+ if (mydive != cd && (copyPaste || same_string(mydive->weightsystem[i].description, cd->weightsystem[i].description))) {
mydive->weightsystem[i] = displayed_dive.weightsystem[i];
+ mydive->weightsystem[i].description = copy_string(displayed_dive.weightsystem[i].description);
+ }
}
);
- for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++)
+ for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
cd->weightsystem[i] = displayed_dive.weightsystem[i];
+ cd->weightsystem[i].description = copy_string(displayed_dive.weightsystem[i].description);
+ }
}
// each dive that was selected might have had the temperatures in its active divecomputer changed
// so re-populate the temperatures - easiest way to do this is by calling fixup_dive