aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-06-20 09:20:32 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-06-20 09:27:11 +0900
commita5380bb741c1081c86353cf5cd7b506b97e02ea9 (patch)
tree7766fa0dd4c359d07d9de95631bc052c5c082e5d /mobile-widgets
parent49f3da3bfd9f336108fd5d4c3977b41e90f75d3f (diff)
downloadsubsurface-a5380bb741c1081c86353cf5cd7b506b97e02ea9.tar.gz
core: add free_samples helper
And use it in the UI and planner code. See #1411 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 8db7df7df..90cf97b2b 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -923,14 +923,10 @@ bool QMLManager::checkDuration(DiveObjectHelper *myDive, struct dive *d, QString
m = r6.cap(1).toInt();
}
d->dc.duration.seconds = d->duration.seconds = h * 3600 + m * 60 + s;
- if (same_string(d->dc.model, "manually added dive")) {
- free(d->dc.sample);
- d->dc.sample = 0;
- d->dc.samples = 0;
- d->dc.alloc_samples = 0;
- } else {
+ if (same_string(d->dc.model, "manually added dive"))
+ free_samples(&d->dc);
+ else
appendTextToLog("Cannot change the duration on a dive that wasn't manually added");
- }
return true;
}
return false;
@@ -947,10 +943,7 @@ bool QMLManager::checkDepth(DiveObjectHelper *myDive, dive *d, QString depth)
d->maxdepth.mm = depthValue;
if (same_string(d->dc.model, "manually added dive")) {
d->dc.maxdepth.mm = d->maxdepth.mm;
- free(d->dc.sample);
- d->dc.sample = 0;
- d->dc.samples = 0;
- d->dc.alloc_samples = 0;
+ free_samples(&d->dc);
}
return true;
}