diff options
author | Jocke <j.bygdell@gmail.com> | 2018-07-29 15:42:56 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-11 11:19:07 -0700 |
commit | 0fb086a4a53dcbd90af01a9faac271d312b485cf (patch) | |
tree | fca0304609cf92a9ae1720e6b8e5f7fcea3d30dd /mobile-widgets/qmlmanager.cpp | |
parent | bd8eec5c8e97050b130bb2d9f02162fe189edbda (diff) | |
download | subsurface-0fb086a4a53dcbd90af01a9faac271d312b485cf.tar.gz |
Mobile: fix saving new dive
With the new setup we need to know which state we are coming from
when we are saving cylinder related info. When we are adding
a new dive we explicitly should save cylinder data to the first cylinder.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 1e62cf0ca..d557d0f34 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1004,7 +1004,7 @@ bool QMLManager::checkDepth(DiveObjectHelper *myDive, dive *d, QString depth) // update the dive and return the notes field, stripped of the HTML junk void QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth, QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes, - QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility) + QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state) { struct dive *d = get_dive_by_uniq_id(diveId.toInt()); @@ -1051,7 +1051,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q if (myDive->startPressure() != startpressure || myDive->endPressure() != endpressure) { diveChanged = true; for ( int i = 0, j = 0 ; j < startpressure.length() && j < endpressure.length() ; i++ ) { - if (!is_cylinder_used(d, i)) + if (state != "add" && !is_cylinder_used(d, i)) continue; d->cylinder[i].start.mbar = parsePressureToMbar(startpressure[j]); @@ -1065,7 +1065,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q // gasmix for first cylinder if (myDive->firstGas() != gasmix) { for ( int i = 0, j = 0 ; j < gasmix.length() ; i++ ) { - if (!is_cylinder_used(d, i)) + if (state != "add" && !is_cylinder_used(d, i)) continue; int o2 = parseGasMixO2(gasmix[j]); @@ -1086,8 +1086,8 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q diveChanged = true; unsigned long i; int size = 0, wp = 0, j = 0, k = 0; - for (j = 0; k < usedCylinder.length() ; j++) { - if (!is_cylinder_used(d, j)) + for (j = 0; k < usedCylinder.length() && j < MAX_CYLINDERS; j++) { + if (state != "add" && !is_cylinder_used(d, j)) continue; for (i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) { |