From a5380bb741c1081c86353cf5cd7b506b97e02ea9 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 20 Jun 2018 09:20:32 +0900 Subject: core: add free_samples helper And use it in the UI and planner code. See #1411 Signed-off-by: Dirk Hohndel --- mobile-widgets/qmlmanager.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'mobile-widgets') 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; } -- cgit v1.2.3-70-g09d2