diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-11-17 10:41:02 +0000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-17 10:41:02 +0000 |
commit | 7196176fa02d80f1690d5d486619c24a1e57a0c4 (patch) | |
tree | 4cc30717ac9324b0dec048d5299e50bfc28111b9 /qt-ui/maintab.cpp | |
parent | ac9c2ba5440c987a4fbda1564d0a2ab7598e48b9 (diff) | |
download | subsurface-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.cpp | 8 |
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 |