mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile: prevent crash adding dives
When the cylinders became a dynamic data structure, a get_cylinder() call suddenly could return a NULL pointer. So use get_or_create_cylinder() for the first call when parsing the user's data. Also, deal with an oddity where the string lists look different because an empty list technically isn't the same as a list with one empty string. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
92ea29ebcb
commit
988ccba710
2 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
Mobile: fix potential crash when adding / editing dives
|
||||||
Mobile: automatically scroll the dive edit screen so that the notes edit cursor stays visible
|
Mobile: automatically scroll the dive edit screen so that the notes edit cursor stays visible
|
||||||
Desktop: ignore dive sites without location in proximity search
|
Desktop: ignore dive sites without location in proximity search
|
||||||
Mobile: add personalized option for units
|
Mobile: add personalized option for units
|
||||||
|
|
|
@ -1122,14 +1122,19 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
|
||||||
d->weightsystems.weightsystems[0].weight.grams = parseWeightToGrams(weight);
|
d->weightsystems.weightsystems[0].weight.grams = parseWeightToGrams(weight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// start and end pressures for first cylinder only
|
// start and end pressures
|
||||||
|
// first, normalize the lists - QML gives us a list with just one empty string if nothing was entered
|
||||||
|
if (startpressure == QStringList(QString()))
|
||||||
|
startpressure = QStringList();
|
||||||
|
if (endpressure == QStringList(QString()))
|
||||||
|
endpressure = QStringList();
|
||||||
if (myDive.startPressure != startpressure || myDive.endPressure != endpressure) {
|
if (myDive.startPressure != startpressure || myDive.endPressure != endpressure) {
|
||||||
diveChanged = true;
|
diveChanged = true;
|
||||||
for ( int i = 0, j = 0 ; j < startpressure.length() && j < endpressure.length() ; i++ ) {
|
for ( int i = 0, j = 0 ; j < startpressure.length() && j < endpressure.length() ; i++ ) {
|
||||||
if (state != "add" && !is_cylinder_used(d, i))
|
if (state != "add" && !is_cylinder_used(d, i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
get_cylinder(d, i)->start.mbar = parsePressureToMbar(startpressure[j]);
|
get_or_create_cylinder(d, i)->start.mbar = parsePressureToMbar(startpressure[j]);
|
||||||
get_cylinder(d, i)->end.mbar = parsePressureToMbar(endpressure[j]);
|
get_cylinder(d, i)->end.mbar = parsePressureToMbar(endpressure[j]);
|
||||||
if (get_cylinder(d, i)->end.mbar > get_cylinder(d, i)->start.mbar)
|
if (get_cylinder(d, i)->end.mbar > get_cylinder(d, i)->start.mbar)
|
||||||
get_cylinder(d, i)->end.mbar = get_cylinder(d, i)->start.mbar;
|
get_cylinder(d, i)->end.mbar = get_cylinder(d, i)->start.mbar;
|
||||||
|
@ -1150,7 +1155,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
|
||||||
he >= 0 && he <= 1000 &&
|
he >= 0 && he <= 1000 &&
|
||||||
o2 + he <= 1000) {
|
o2 + he <= 1000) {
|
||||||
diveChanged = true;
|
diveChanged = true;
|
||||||
get_cylinder(d, i)->gasmix.o2.permille = o2;
|
get_or_create_cylinder(d, i)->gasmix.o2.permille = o2;
|
||||||
get_cylinder(d, i)->gasmix.he.permille = he;
|
get_cylinder(d, i)->gasmix.he.permille = he;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
|
@ -1177,7 +1182,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get_cylinder(d, j)->type.description = copy_qstring(usedCylinder[k]);
|
get_or_create_cylinder(d, j)->type.description = copy_qstring(usedCylinder[k]);
|
||||||
get_cylinder(d, j)->type.size.mliter = size;
|
get_cylinder(d, j)->type.size.mliter = size;
|
||||||
get_cylinder(d, j)->type.workingpressure.mbar = wp;
|
get_cylinder(d, j)->type.workingpressure.mbar = wp;
|
||||||
k++;
|
k++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue