summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-22 16:22:21 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-22 16:22:21 -0700
commit7bf07b890a3530dabb4c00621a76c88ea3177702 (patch)
tree9f612f4886070618d2863879f6ad4d0df334de6f /qt-ui
parent76903849de8da124d737a8ecd615cec259504a4e (diff)
downloadsubsurface-7bf07b890a3530dabb4c00621a76c88ea3177702.tar.gz
Small fixes to the model
Prevent a crash when no cylinder type description is set. Correctly calculate the cylinder volume. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/models.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index b38295bc5..eb5a9a5b4 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -123,7 +123,7 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in
case TYPE:
if (!value.isNull()) {
char *text = value.toByteArray().data();
- if (strcmp(cyl->type.description, text)) {
+ if (!cyl->type.description || strcmp(cyl->type.description, text)) {
cyl->type.description = strdup(text);
mark_divelist_changed(TRUE);
}
@@ -431,9 +431,10 @@ QVariant TankInfoModel::data(const QModelIndex& index, int role) const
int bar = ((info->psi) ? psi_to_bar(info->psi) : info->bar) * 1000 + 0.5;
- if (info->cuft) {
- double airvolume = cuft_to_l(info->cuft) * 1000.0;
- ml = airvolume / bar_to_atm(bar) + 0.5;
+ if (info->cuft && info->psi) {
+ pressure_t p;
+ p.mbar = psi_to_mbar(info->psi);
+ ml = wet_volume(info->cuft, p);
}
if (role == Qt::DisplayRole) {
switch(index.column()) {