diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-02-20 07:33:05 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-02-20 07:33:05 -0800 |
commit | 5fc16910c26a8944a41840360e232bdf3c2468a7 (patch) | |
tree | 06c1d0efdf8f454bb6f16b97078077a279b6f98c | |
parent | 97d6a1e779c91c434e00086c90e0e8b3fcf540dc (diff) | |
download | subsurface-5fc16910c26a8944a41840360e232bdf3c2468a7.tar.gz |
QML UI: fix recreation of profile after dive edit
We only need to deal with this if the dive changed. And in that case, if
we calculate a new fake DC, we need to clear out the meandepth as
otherwise the algorithm will try to match both max and mean depth. Since
the user potentially changed the max depth that could have very odd
consequences.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index ede1d3a6b..009b21fe8 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -545,17 +545,20 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location diveChanged = false; // because we already modified things } } - if (d->maxdepth.mm == d->dc.maxdepth.mm && - d->maxdepth.mm > 0 && - same_string(d->dc.model, "manually added dive") && - d->dc.samples == 0) { - // so we have depth > 0, a manually added dive and no samples - // let's create an actual profile so the desktop version can work it - d->dc = *fake_dc(&d->dc); - } - if (diveChanged) + if (diveChanged) { + if (d->maxdepth.mm == d->dc.maxdepth.mm && + d->maxdepth.mm > 0 && + same_string(d->dc.model, "manually added dive") && + d->dc.samples == 0) { + // so we have depth > 0, a manually added dive and no samples + // let's create an actual profile so the desktop version can work it + // first clear out the mean depth (or the fake_dc() function tries + // to be too clever + d->meandepth.mm = d->dc.meandepth.mm = 0; + d->dc = *fake_dc(&d->dc); + } DiveListModel::instance()->updateDive(oldIdx, d); - + } if (diveChanged || needResort) { mark_divelist_changed(true); // this is called "commit" for a reason - when the user saves an |