aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-12-11 22:34:35 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-12-13 11:49:59 -0800
commit50b11024d685129e78c36313b892dbc0e55c654c (patch)
tree96d56180e18ae2e11a7e4f3a6d86944883738797 /mobile-widgets/qmlmanager.cpp
parent2e328c7633c1de43af000fd6506385c651365a0d (diff)
downloadsubsurface-50b11024d685129e78c36313b892dbc0e55c654c.tar.gz
core: keep tank infos in a dynamic table
The list of known tank types were kept in a fixed size table. Instead, use a dynamic table with our horrendous table macros. This is more flexible and sensible. While doing this, clean up the TankInfoModel, which was leaking memory. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 10f6f11e5..1b5c1ed17 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1156,20 +1156,20 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
// info for first cylinder
if (myDive.getCylinder != usedCylinder) {
diveChanged = true;
- unsigned long i;
int size = 0, wp = 0, j = 0, k = 0;
for (j = 0; k < usedCylinder.length(); j++) {
if (state != "add" && !is_cylinder_used(d, j))
continue;
- for (i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) {
- if (tank_info[i].name == usedCylinder[k] ) {
- if (tank_info[i].ml > 0){
- size = tank_info[i].ml;
- wp = tank_info[i].bar * 1000;
+ for (int i = 0; i < tank_info_table.nr; i++) {
+ const tank_info &ti = tank_info_table.infos[i];
+ if (ti.name == usedCylinder[k] ) {
+ if (ti.ml > 0){
+ size = ti.ml;
+ wp = ti.bar * 1000;
} else {
- size = (int) (cuft_to_l(tank_info[i].cuft) * 1000 / bar_to_atm(psi_to_bar(tank_info[i].psi)));
- wp = psi_to_mbar(tank_info[i].psi);
+ size = (int) (cuft_to_l(ti.cuft) * 1000 / bar_to_atm(psi_to_bar(ti.psi)));
+ wp = psi_to_mbar(ti.psi);
}
break;
}
@@ -1816,8 +1816,8 @@ QStringList QMLManager::cylinderInit() const
}
}
- for (unsigned long ti = 0; ti < MAX_TANK_INFO && tank_info[ti].name != NULL; ti++) {
- QString cyl = tank_info[ti].name;
+ for (int ti = 0; ti < tank_info_table.nr; ti++) {
+ QString cyl = tank_info_table.infos[ti].name;
if (cyl == "")
continue;
cylinders << cyl;