From 5fc16910c26a8944a41840360e232bdf3c2468a7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 20 Feb 2016 07:33:05 -0800 Subject: 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 --- qt-mobile/qmlmanager.cpp | 23 +++++++++++++---------- 1 file 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 -- cgit v1.2.3-70-g09d2